I
I
Ivan Simonov2018-02-02 18:03:38
css
Ivan Simonov, 2018-02-02 18:03:38

How to pass background-gradient to jQuery?

Hello!

For example, to transfer one color - https://jsfiddle.net/vhe9ek72/

But for a gradient, this option does not work - https://jsfiddle.net/0hk9xyLk/

Tell me how to transfer background-gradient?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Fedotov, 2018-02-02
@ivansimonov1984

(function() {
  var buttonsColor = $('button[data-color]');

  buttonsColor.each(function() {
  var customColor = $(this).attr("data-color");
    $(this).attr('style',"background: "+customColor+";");
  });

})();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question