I'm pulling my hair out trying to figure out why the mouseover event won't work with the .on handler with a dynamically created element from ajax. The only thing that seems to work is the code with .live but I understand that it is deprecated.
$(".dropdown ul li").live("mouseover", function() {
alert('mouseover works');
});
However, when I try using .on, it will not work - no matter what variations I try (document.ready, .mouseover, etc etc)
$(".dropdown ul li").on("mouseover", function() {
alert('mouseover works');
});
The event handlers are at the bottom of the code, so they are executed last. Anyone have an idea of what I'm doing wrong??
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…