Thursday, 5 September 2013

Can I use each for elements create on the fly?

Can I use each for elements create on the fly?

Hello can I use each for elements that they are created on the fly?
$('#cart-info .shopp').each(function(){
var cartitem = $(this);
alert(cartitem);
cartitem.find('img.remove').on('click',function(){
alert(cartitem.attr('id'));
});
});
I created elements under div cart-info. But unfortenately the click event
does not work. If the elements are provided when the page loads it works.
For example look at http://jsfiddle.net/epapathanasiou/jpdZt/1/

No comments:

Post a Comment