-3

Currently I'm working on a little project and want to know how to add gradient to text using JavaScript like in CSS.

1 Answers1

0

Adding gradient to text using JS is as same as adding it using CSS

According to CSS written on CSS Tricks it's possible to add in JS using this code

const h1 = document.getElementsByTagName('h1')[0];
h1.style.background = 'linear-gradient(#eee, red)';
h1.style.webkitBackgroundClip = 'text';  
h1.style.webkitTextFillColor = 'transparent';
joka00
  • 2,357
  • 1
  • 10
  • 27