I add a delete button dynamically to the page once the user uploads an image.
$('.galleryImage .delete').bind('click', function() {
//do delete
}
The above does not work.
As I understand it, it’s because the delete button is added to the page after creation.
I’ve tried
$('body').on('click', '.galleryImage .delete', function() {
But this only works with jquery 1.7+ and I need to use 1.6.
Any ideas how I can get this to work?
As you want to use in jQuery 1.6 so you can use
.delegate()event handling.but would be better if you use jquery 1.7
and
.on()event handlerAccording to comment
if
.galleryImageis dynamically added then you should use aStatic-elementthat is container of.galleryImage, that means the container should not dynamic.