loop gradient directions by clicking on a target

前端 未结 3 1454
借酒劲吻你
借酒劲吻你 2021-01-29 02:11

I need to loop all of the eight gradient directions by clicking on a target, like this:

3条回答
  •  粉色の甜心
    2021-01-29 02:28

    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];
    

提交回复
热议问题