Getting the class of the element that fired an event using JQuery

后端 未结 6 1280
独厮守ぢ
独厮守ぢ 2021-01-30 08:04

is there anyway to get the class when click event is fired. My code as below, it only work for id but not class.

6条回答
  •  臣服心动
    2021-01-30 08:40

    If you are using jQuery 1.7:

    alert($(this).prop("class"));
    

    or:

    alert($(event.target).prop("class"));
    

提交回复
热议问题