Javascript/jQuery - How do I obtain name of the class of clicked element?

前端 未结 6 1564
礼貌的吻别
礼貌的吻别 2020-12-16 00:27

I googled and googled and I concluded that it\'s very hard to get answer on my own.

I am trying to use jquery or JavaScript to get a property of clicked element. I c

6条回答
  •  一整个雨季
    2020-12-16 00:56

    $('#ele').click(function() {
        alert($(this).attr('class'));
    });
    

    And here are all of the attribute functions.

    http://api.jquery.com/category/attributes/

提交回复
热议问题