here demo of code. want show id of button while saying undefined
code:
$('#btn').on('click', function () { var $this = $(this); var id = $(this).id; alert(id); });
simply use dom native functions , properties:
$('#btn').on('click', function () { alert(this.id); }); if decided want use jquery overkill:
alert($(this).attr('id'));
Comments
Post a Comment