on的用法问题
因为元素是ajax输出,所以需要用到on,
但是用了on还是没效果,请大家帮忙看看写法哪里错了,
需要达到效果:鼠标移动到元素上弹出对话框,代码如下
$(document).on("hover","#menutest2", function(){
alert ("有效");
});
$('#menutest2').live('hover', function() {
alert ("有效");
});
$(document).on("mouseenter","#menutest2", function(){
alert ("in");
});
$(document).on("mouseleave","#menutest2", function(){
alert ("out");
});
<script>
$(document).ready(function(e) {
$(document).on('mouseover','#menutest2', function(){
alert ("有效");
});
});
</script>