I have a dynamically generated thumbnail images on the left side of my popup and on click of the image i want that image to be displayed on the right hand side.
I am usi
Try event delegation approach here where in the events are associated to the elements ancestor ..
By doing so because of bubbling effect the click event will be associated to the image element in such cases...
$(".photoright").on('click', 'img', function(){
alert(this);
});
Make sure the id in your document is unique.
So instead of id="citythumb" declare class="citythumb"
Please move the sliderimage() function outside of Ajax call
$.ajax({
});
function sliderimage(image){
alert("sdf");
alert(image);
}
id="citythumb"
must be unique, use class
, like class="citythumb"
$(".photoright").on('click', 'img', function(e){
e.preventDefault(); // for link
alert(this);
});
when you change id
attribute, you could also replace img
with .citythumb