I’m trying the get the ID of a button using $(this).id, but it’s coming up as undefined. What am I doing wrong? Thanks for reading.
EDIT: Code from jsFiddle example:
HTML
<button id='remove_button' type='button'>Remove</button>
jQuery
$('#remove_button').mouseup(function(){
alert($(this).id);
});
$(this)Gives you a reference to a jQuery object. You can either use the attr() function like Mario says, or even just do this:
this.id