I need to loop all of the eight gradient directions by clicking on a target, like this:
Instead of background, you can get the style attribute.
$(this).attr('style')
It will return "background: linear-gradient(to top,red,yellow)"
.
Then you use .slice(28)
to cut out "background: linear-gradient("
and .split(',')[0]
to get the direction.
let a = $(this).attr('style').slice(28).split(',')[0];