How do I access the ID of an LI using jQuery?
How do I get the ID of a list element? Whenever I use this.id
it gives me the ID of the parent table. Here's my code:
$('*').bind('tap', function() {
selectBrick(this.id);
开发者_运维技巧 alert(this.id)
});
It seems your selector '*'
is binding the tap event to the table. You could try to use the event object and see if what target
is - this should be the DOM element that was actually subjected to the event.
$('*').bind('tap', function(event) {
selectBrick(event.target.id);
alert(event.target.id)
});
精彩评论