How can I get the current class of a div with jQuery?

后端 未结 11 457
挽巷
挽巷 2020-12-03 00:19

Using jQuery, how can I get the current class of a div called div1?

11条回答
  •  暖寄归人
    2020-12-03 01:09

    if you want to look for a div that has more than 1 class try this:

    Html:

    Jquery:

    var check = $( "#myDiv" ).hasClass( "class2" ).toString();
    

    ouput:

    true

提交回复
热议问题