How to check the background-color of an element using jquery

前端 未结 5 913
闹比i
闹比i 2021-01-05 10:42
if($(this).css(\"background-color\")==Crimson) 

is this correct ? .css(\"background-color\",\"white\") will change the color, but I don\'t want t

5条回答
  •  日久生厌
    2021-01-05 11:31

    just use below line

    if($(this).css("background-color")=="crimson") 
    

    as css("background-color") attribute result will be in small letters . so if you will compare with capital obviously it will return false. :) Small trick hope that work

提交回复
热议问题