I have two lists with different classes,
<li><a href='#' class="cls1" name="X">blah</a></li> <!-- Click to load a cls2 item -->
<li><a href='#' class="cls1" name="Y">blah</a></li>
<li><a href='#' class="cls2" name="A">blah</a></li>
<li><a href='#' class="cls2" name="B">blah</a></li>
I have this script to handle click function.
$(function(){
$('.cls1').click(function(e){
alert('cls1 clicked');
e.preventDefault();
... //ajax call to load cls2 items
});
$('.cls2').click(function(e){
alert('cls2 clicked');
e.preventDefault();
...
});
)};
Important The cls2 class items are loaded by an ajax function called in cls1 click function
The cls1 items click function works fine, but when i click any cls2 item, nothing happens.
Is there any problem by adding it after the whole page loads? (by ajax call)
Another issue I notted is that if i refresh the page, and i change the cls1 class to cls2 in the code (using chrome console) the css changes correctly but it still doing the cls1 click function. Why???
Any Idea? I have tried to change the click function order, change the class names, even with another jquery library... (I am using v1.11.1)
Issue example here: http://jsfiddle.net/f7o5y3ek/