gpt4 book ai didi

jquery - 在 jQuery 代码中添加 MouseOut

转载 作者:行者123 更新时间:2023-12-01 02:32:29 25 4
gpt4 key购买 nike

我正在尝试制作一个 div jQuery 代码,以便在鼠标悬停在另一个 div 上后显示一个 div!

jQuery:

$(document).ready(function() {
$('.pic').mouseover(function() {
$('.rank').fadeOut(200);
$(this).next('.rank').fadeIn(400);
});

$("div.rank").hide();
});​

HTML:

<div class="pic">Mouse Over</div>
<div class="rank">Show Somthing</div>​

演示:http://jsfiddle.net/CaMwL/

现在,问题是,我需要向此代码添加 mouseout 事件,我想在将鼠标移出时隐藏 div!我不知道我该怎么做!

最佳答案

试试这个:http://jsfiddle.net/633hD/1/

您可以链接 API:.mouseout http://api.jquery.com/mouseout/

希望它符合原因:)

代码

$(document).ready(function() {
$("div.rank").hide();

$('.pic').mouseover(function() {
$('.rank').fadeOut(200);
$(this).next('.rank').fadeIn(400);
}).mouseout(function() {
$("div.rank").hide();
});
});​

关于jquery - 在 jQuery 代码中添加 MouseOut,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12792702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com