Getting data-* attribute for onclick event for an html element

前端 未结 7 1167
一个人的身影
一个人的身影 2020-12-22 23:33

       Click to do something

I wan

7条回答
  •  生来不讨喜
    2020-12-23 00:21

    I simply use this jQuery trick:

    $("a:focus").attr('data-id');
    

    It gets the focused a element and gets the data-id attribute from it.

提交回复
热议问题