jQuery getting ID of clicked link

前端 未结 6 2039
醉话见心
醉话见心 2020-12-18 10:22

I have a modal box in jQuery which I have created to display some embed code. I want the script to take the id of the link that is clicked but I can\'t

6条回答
  •  悲哀的现实
    2020-12-18 10:53

    Instead of referencing the class, which will grab all members of that class, you need to reference $(this) so you can get that unique link when it is clicked.

    var answerid = $(this).prop('id');
    

提交回复
热议问题