Reputation: 41
I have an jquery script using .ajax that loads a new div containing the replied information. Part of the contents of that div is a link that says remove. When remove is clicked I want the parent div to hide. This doesn't seem to work.
$(document).ready(function(){
$('.remove').click(function() {
$('.remove').parent().hide();
});
});
This has no effect what so ever. This code seems to work if the div I am trying to work with isn't loaded with ajax. Any ideas?
Upvotes: 3
Views: 1024
Reputation: 293
Try live (added in 1.3):
$(document).ready(function(){
$('.remove').live('click', function() {
$('.remove').parent().hide();
});
});
Man: http://api.jquery.com/live/
Upvotes: 4