Say we have a simple event button handler:
$( \"#aButton\" ).click(function() {
console.log( \"tile\" + this.val() + \"clicked\" );
});
I re
The object that you clicked can be referred by this
, so saying this.id
will give you button's id "aButton". However, if you want to use jQuery's methods then you have to say $(this).attr('id')
which will again give you "aButton".
So you do have different mechanisms available to you but if you are using jQuery, it is preferable to use jQuery methods.