I have a situation where only the first click of an image works, the second time when clicked the other function doesn't run.
<script>
jQuery(document).ready(function($) {
$('#temp_container img').click(function(){
var img = $('#temp_container img').attr('src');
$('#temp_container2').append('<img src="'+img+'">');
});
$('#temp_container2 img').click(function(){
alert('works');
});
});
</script>
<div id="temp_container">
<img src="http://cdn-images.farfetch.com/10/62/22/35/10622235_3103339_170.jpg">
</div>
<div id="temp_container2"></div>
When you click on the image in div temp_container, the image is duplicated and appended to temp_container2, when clicking on the image in div temp_container2 an alert should be executed. But for some reason this doesn't execute when run. I've been stuck on this issue for hours.
Thanks