I have list of dynamic created elements which when clicked fires a ajax request and displays the result. The problem is it works only when it is clicked twice. The first click on element doesn't work. Whereas the second click works perfectly. I don't understand the reason behind this. I did try unbind()
but it didn't help
$("#profiles_name ul a").on('click',function(event){
$.ajax({
}
});
});.
I did try $("#profiles_name ul a").unbind().on('click',function(event)..
It didnt work still.
Here is my dynamically created tag
<ul>
<a href="javascript:myfunction(this)" data-value="20/20"><li>Frontend Dev</li></a>
<li class="divider"></li>
</ul>
Also to keep in note that, For example if i have two dynamically created list, When i click on list 1(first time) it doesnt work list 1( second time) works. After page refresh, click on list 1(first time) doesn't work and click on list 2 (first time) works. i.e First click doesnt work irrespective of the dynamically created element.