jquery hover问题
$("#"+vid).hover(function(){mars=setTimeout(function(){alert("1231qweqwe");},2000);},...
$("#"+vid).hover(function(){
mars=setTimeout(function(){
alert("1231qweqwe");
},2000) ;
},function(){
alert("jjjjjjjjjjjjjjjjjjjj");
clearTimeout(mars);
});
上面这段代码,当鼠标移入元素一直不离开会一直执行hover里面的函数,而且移入元素后满足延迟时间2000毫秒会首先执行最后一个函数,也就是会先alert("jjjjjjjjjjjjjjjjjjjj"); 然后再alert("1231qweqwe");
请大家赐教了 展开
mars=setTimeout(function(){
alert("1231qweqwe");
},2000) ;
},function(){
alert("jjjjjjjjjjjjjjjjjjjj");
clearTimeout(mars);
});
上面这段代码,当鼠标移入元素一直不离开会一直执行hover里面的函数,而且移入元素后满足延迟时间2000毫秒会首先执行最后一个函数,也就是会先alert("jjjjjjjjjjjjjjjjjjjj"); 然后再alert("1231qweqwe");
请大家赐教了 展开
展开全部
$(function () {
var mouseover_tid = [];
var mouseout_tid = [];
$(".navLink").each(function (index) {
$(this).hover(function () {
var self = this;
clearTimeout(mouseout_tid[index]);
mouseover_tid[index] = setTimeout(function () {
$(self)
.children("ul")
.css("left", $("#box").offset().left)
.slideDown('slow')
.end()
.find(".triangle")
.css("background", "url('../Images/hovertri.jpg') no-repeat right center")
.end()
.find(".item")
.css("background", "url('../Images/hover.jpg')");
}, 400);
}, function () {
var self = this;
clearTimeout(mouseover_tid[index]);
mouseout_tid[index] = setTimeout(function () {
$(self)
.children("ul")
.slideUp()
.end()
.find(".triangle")
.css("background", "url('../Images/triangle1.jpg') no-repeat right center")
.end()
.find(".item")
.css("background", "none");
}, 400);
});
});
});
这是我在网上找的一段代码,感觉效果还不错,你自己看下改吧~
var mouseover_tid = [];
var mouseout_tid = [];
$(".navLink").each(function (index) {
$(this).hover(function () {
var self = this;
clearTimeout(mouseout_tid[index]);
mouseover_tid[index] = setTimeout(function () {
$(self)
.children("ul")
.css("left", $("#box").offset().left)
.slideDown('slow')
.end()
.find(".triangle")
.css("background", "url('../Images/hovertri.jpg') no-repeat right center")
.end()
.find(".item")
.css("background", "url('../Images/hover.jpg')");
}, 400);
}, function () {
var self = this;
clearTimeout(mouseover_tid[index]);
mouseout_tid[index] = setTimeout(function () {
$(self)
.children("ul")
.slideUp()
.end()
.find(".triangle")
.css("background", "url('../Images/triangle1.jpg') no-repeat right center")
.end()
.find(".item")
.css("background", "none");
}, 400);
});
});
});
这是我在网上找的一段代码,感觉效果还不错,你自己看下改吧~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询