How check if body has a specific class with JavaScript?

后端 未结 7 1858
不思量自难忘°
不思量自难忘° 2021-01-01 16:40

How can I check if body has specific class? This is my case:


7条回答
  •  伪装坚强ぢ
    2021-01-01 17:19

    This returns a string of true or false when looking for a specific body class using jQuery's .hasClass:

    if ($("body").hasClass("modal-open")) {
                            $("body").removeClass("modal-open");
                        }
    

提交回复
热议问题