How to get the class of the clicked element?

后端 未结 6 1806
抹茶落季
抹茶落季 2020-11-29 16:34

I can\'t figure it out how to get the class value of the clicked element.

When I use the code bellow, I get \"node-205\" every time

6条回答
  •  攒了一身酷
    2020-11-29 16:44

    $("div").click(function() {
      var txtClass = $(this).attr("class");
      console.log("Class Name : "+txtClass);
    });
    

提交回复
热议问题