悬停淡入,重复
当用户将鼠标悬停在 div1 上时: -
- div1 和 div2 的内容淡出
- div1 加载一些新内容
- div2 在 div1 现有内容中淡出
这是我希望停止的地方。
然而,当 div1 的新内容加载时,悬停事件再次触发,并且这种情况继续下去。
我怎样才能做到在初始悬停事件之后,悬停事件不会再次发生,直到用户删除光标并再次悬停在 div1 上?
希望这是有道理的,提前欢呼!
$('document').ready(function () {
//For each small block
$('#div1').hover(function () {
var thisWish = $(this).html();
var nextWish = $('#wishy1').html();
//Fade the small block out bring in a new wish
$(this).fadeOut(1200, function () {
$(this).html(nextWish).fadeIn(1200, function () {
});
});
//Fade the large block and and bring in the small blocks wish
$('#div2').fadeOut(1200, function () {
$('#div2').html(thisWish).fadeIn(1200, function () {
});
});
},
function () {
// hover out
});
});
When a user hovers over div1: -
- div1 and div2's contents fadeout
- div1 loads some new content
- div2 fades in div1s existing content
This is where I want this to stop.
However, when the new contents of div1 load, the hover event triggers again, and this continues.
how can i make it so after the initial hover event, the hover event wont occur again until the user has removed the cursor and hovered again on div1?
hope this makes sense, cheers in advance!
$('document').ready(function () {
//For each small block
$('#div1').hover(function () {
var thisWish = $(this).html();
var nextWish = $('#wishy1').html();
//Fade the small block out bring in a new wish
$(this).fadeOut(1200, function () {
$(this).html(nextWish).fadeIn(1200, function () {
});
});
//Fade the large block and and bring in the small blocks wish
$('#div2').fadeOut(1200, function () {
$('#div2').html(thisWish).fadeIn(1200, function () {
});
});
},
function () {
// hover out
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您没有使用hover的第二个事件,因此请使用mouseover:
Since you're not using the second event of the hover, use mouseover instead: