jQuery getting ID of clicked link

前端 未结 6 2032
醉话见心
醉话见心 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:50

     $('.openembed').click(function () {
        generateCode();
        var answerid = $(this).attr('id');
        $('#box').show();
        return false;
    });
    

    Use $(this). $('.openembed') refers to multiple links.

提交回复
热议问题