悬停时的javascript在ajax加载上不起作用?
我正在使用以下代码进行悬停。但此代码在ajaxload上不起作用悬停时的javascript在ajax加载上不起作用?,javascript,jquery,Javascript,Jquery,我正在使用以下代码进行悬停。但此代码在ajaxload上不起作用 <script type="text/javascript"> jQuery(document).ready(function(){ jQuery('.products-grid .item').hover(function(){ jQuery(this).find('.pro-review').animate({bottom:'0'}, 200); jQuery(this).
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('.products-grid .item').hover(function(){
jQuery(this).find('.pro-review').animate({bottom:'0'}, 200);
jQuery(this).find('.pro-view').show();
}, function(){
jQuery(this).find('.pro-review').stop(true,true).animate({bottom:'-37'}, 200);
jQuery(this).find('.pro-view').hide();
});
)};
</script>
如何将诸如
.on(“hover”、“.products grid.item”、function()
之类的内容与我用于第一个函数的第二个函数相关联您可以使用mouseleave
和mouseenter
而不是将鼠标悬停
与on关联
jQuery(document).on("mouseleave",".products-grid .item", function () {
jQuery(this).find('.pro-review').animate({bottom:'0'}, 200);
jQuery(this).find('.pro-view').show();
});
jQuery(document).on("mouseenter",".products-grid .item", function () {
jQuery(this).find('.pro-review').stop(true,true).animate({bottom:'-37'}, 200);
jQuery(this).find('.pro-view').hide();
});
或者您可以将mouseenter
和mouseleave
$(document).on({
mouseenter: function () {
jQuery(this).find('.pro-review').animate({bottom:'0'}, 200);
jQuery(this).find('.pro-view').show();
},
mouseleave: function () {
jQuery(this).find('.pro-review').stop(true,true).animate({bottom:'-37'}, 200);
jQuery(this).find('.pro-view').hide();
}
}, '.products-grid .item');
您可以使用
mouseleave
和mouseenter
代替启用时的hover
jQuery(document).on("mouseleave",".products-grid .item", function () {
jQuery(this).find('.pro-review').animate({bottom:'0'}, 200);
jQuery(this).find('.pro-view').show();
});
jQuery(document).on("mouseenter",".products-grid .item", function () {
jQuery(this).find('.pro-review').stop(true,true).animate({bottom:'-37'}, 200);
jQuery(this).find('.pro-view').hide();
});
或者您可以将mouseenter
和mouseleave
$(document).on({
mouseenter: function () {
jQuery(this).find('.pro-review').animate({bottom:'0'}, 200);
jQuery(this).find('.pro-view').show();
},
mouseleave: function () {
jQuery(this).find('.pro-review').stop(true,true).animate({bottom:'-37'}, 200);
jQuery(this).find('.pro-view').hide();
}
}, '.products-grid .item');
“悬停”
实际上不是它自己的事件,而是一个:
调用$(选择器)。悬停(handlerIn,handlerOut)
是以下内容的简写:
$(selector).mouseenter(handlerIn).mouseleave(handlerOut);
对于委托绑定,您可以直接指定它们:
jQuery(document).on({
'mouseenter': function(){
jQuery(this).find('.pro-review').animate({bottom:'0'}, 200);
jQuery(this).find('.pro-view').show();
},
'mouseleave': function(){
jQuery(this).find('.pro-review').stop(true,true).animate({bottom:'-37'}, 200);
jQuery(this).find('.pro-view').hide();
}
}, '.products-grid .item');
“悬停”
实际上不是它自己的事件,而是一个:
调用$(选择器)。悬停(handlerIn,handlerOut)
是以下内容的简写:
$(selector).mouseenter(handlerIn).mouseleave(handlerOut);
对于委托绑定,您可以直接指定它们:
jQuery(document).on({
'mouseenter': function(){
jQuery(this).find('.pro-review').animate({bottom:'0'}, 200);
jQuery(this).find('.pro-view').show();
},
'mouseleave': function(){
jQuery(this).find('.pro-review').stop(true,true).animate({bottom:'-37'}, 200);
jQuery(this).find('.pro-view').hide();
}
}, '.products-grid .item');
将另一个监听器添加到
mouseleave
,该监听器应执行此操作将另一个监听器添加到mouseleave
,该监听器应执行此操作