jQuery If DIV Doesn't Have Class “x”

后端 未结 7 2326
庸人自扰
庸人自扰 2020-11-27 10:54

In jQuery I need to do an if statement to see if $this doesn\'t contain the class \'.selected\'.

$(\".thumbs\").hover(function(){

$(this).stop().fadeTo(\"no         


        
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 11:19

    You can also use the addClass and removeClass methods to toggle between items such as tabs.

    e.g.

    if($(element).hasClass("selected"))
       $(element).removeClass("selected");
    

提交回复
热议问题