I have a page which loads subsequent pages through ajax on the same page. I want to add click event on selected elements. Though it is easy to add elements from first page but how can I add new elements to selected ones from ajax response?
Eg. Each page 10 article tags like this
<article>
<ul>
<li>123</li>
<li>qwe</li>
<li>abc</li>
</ul>
</article>
Code for first page:
$('li').click(function(){
// code
});
I tried to add new elements by unbinding click event and then binding them again but is this efficient when 20 or more pages are ajax loaded?
Code after ajax response of subsequent pages:
$('li').unbind('click');
$('li').click(function(){
// code
});