Here is the thing
Suppose I have an html with the following structure:
<div id="click"> add</div>
<div id="id">
<div class="item">1</div>
<div class="item">2</div>
</div>
and I have created some events on click on this “item” class via jquery.
$('.class').click(function(){ alert('1');})
The problem is, that I want to add another “item” by clicking on “click” div by stated below javascript
$('#click').click(function(){
$('#id').prepend('<div class="item">new</div>');
})
and of course I want this “item” to be clickable as well, but there is no handler on it.
of course I can add it by evoking $(‘.class’).click(…. one more time, but this is not the case because there will be 2 events on “item” 1 and “item” 2 divs.
Can anyone suggest something?
Thanks in advance
You could probably solve this problem using .live()