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

前端 未结 5 888
闹比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:15

    Use quotes around the color name as:

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

    otherwise it is right.

提交回复
热议问题