我在IE浏览器中使用insertbefore脚本在jquery悬停函数中遇到问题。
目前我需要在悬停时交换两个div。所以我在drupal7中用脚本插入了脚本。
它在IE浏览器以外的所有浏览器中都能正常工作。
这是我的代码
$( '.block-views .view-collaborater-view .views-row.views-row-2' )
.mouseover(function() {
console.log('mouseover');
$('.block-views .view-collaborater-view .views-row.views-row-2').insertBefore($('.block-views .view-collaborater-view .views-row.views-row-1'));
$('.block-views .view-collaborater-view .views-row.views-row-2').css('width','98%');
})
.mouseout(function() {
console.log('mouseleave');
$('.block-views .view-collaborater-view .views-row.views-row-2').css('width','48%');
$('.block-views .view-collaborater-view .views-row.views-row-1').insertBefore($('.block-views .view-collaborater-view .views-row.views-row-2'));
});
先谢谢。
答案 0 :(得分:0)
尝试像这样使用,如果与某个类名不匹配,请抱歉
$(document).on("mouseenter", ".block-views .view-collaborater-view .views-row.views-row-2" function(){
console.log('mouseover');
$(this).insertBefore($('.block-views .view-collaborater-view .views-row.views-row-1'));
$(this).css('width','98%');
});
$(document).on("mouseleave", ".block-views .view-collaborater-view .views-row.views-row-2" function(){
console.log('mouseleave');
$('.block-views .view-collaborater-view .views-row.views-row-1').insertBefore($('.block-views .view-collaborater-view .views-row.views-row-2'));
$(this).css('width','48%');
});