I wrote somthing like this:
<body>
<div class="item">An Item</div>
<body>
I created this with a jQuery event.
$("button").click(function(){
$(body).append("<div class="item>An Item</div>");
});
so now i have something like this:
<body>
<div class="item">An Item</div>
<div class="item">A New Item Created With jQuery Event</div>
</body>
The problem: I want to do this, to get the info from both divs.
$(".item").click(function(){
$(this).text();
});
Works fine with the original .item from the HTML. But it doesnt work with the newly created element with jQuery. Why is that?