Reputation: 19133
With Jquery v1.5.2 following function works, I have upgraded jquery to 1.9.1 live has been replaced to on function. if I change live to on. its not working.
I changed on to live and included the migration plugin its working. how can I use this with on function
$( ".pop-up" ).live(
"click",
function( event ){
// get the id of the item clicked on
var id = $(this).attr('id');
alert(id)
// block the href actually working
return( false );
});
Upvotes: 0
Views: 723
Reputation: 123739
Try this
Instead of document you could use the selector that already exists in DOM, If this element is added dynamically to the DOM at a later time.
$(function(){
$(document).on("click", ".pop-up",
function( event ){
// get the id of the item clicked on
var id = $(this).attr('id');
alert(id)
// block the href actually working
return( false );
});
});
Upvotes: 1