开发者

How to identify when a dynamic button is clicked using JQuery?

开发者 https://www.devze.com 2023-03-09 21:28 出处:网络
I am dynamically creating a bunch of buttons <a href=\"#\" id=\"btnRemove\" class=\"ui-state-default ui-corner-all\"><span class=\"ui-icon ui-icon-close\"></span>REMOVE</a>

I am dynamically creating a bunch of buttons

<a href="#" id="btnRemove" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-close"></span>REMOVE</a>
开发者_运维技巧

but how do I identify which one of them was clicked?


If you register for the click event the this variable inside this callback will point to the corresponding DOM element that was clicked:

$('a').click(function() {
    // this here will represent the anchor that was clicked
    return false;
});
0

精彩评论

暂无评论...
验证码 换一张
取 消