Forum Moderators: open
<div id="classifiedList">
<div id="itemList">
<div id="fragLoad">
<div data-listid="12345">
<div class="float_left"><img ...></div>
<div class="float_left">
<div>Title</div>
<div>Description</div>
</div>
</div>
</div>
</div>
</div> $(function() {
$('#fragLoad').on('click', function(event) {
alert($(event.target).data('listid'));
});
}); $(function() {
$('#fragLoad').on('click', '[data-listid]', function(event) {
console.log($(this).data('listid'));
});
}); $(function() {
$('[data-listid]').on('click', function(event) {
console.log($(this).data('listid'));
});
}); $(function() {
$('#fragLoad').on('click', '[data-listid]', function(event) {
if ($(this).data('listid'))
console.log($(this).data('listid'));
});
}); Using [data-listid] as the selector seemed to work perfect, even if I click on the image. Maybe what you described is browser-specific? Either way, I added a condition so if there's no data-listid then nothing happens
FWIW, I don't have a repeating ID, though
Having previously seen the page, you do seem to be repeating IDs like fragLoad and itemList with every new set of items added to the document through the infinite scroll mechanism. Not sure if it's a problem for jQuery though.