Jquery - 将 fadeIn / fadeOut 添加到悬停 addclass 函数

发布于 2024-10-07 21:06:25 字数 1159 浏览 0 评论 0原文

好吧,这是我当前的 jquery 代码,它在 div“fbox”悬停时通过更改 div“fbot”的类来替换背景

    <script>
 $(document).ready(function () {
$(function() {
     $("#fbox").hover(function () {
        $("#fbot").addClass("fboto");
    },
    function () {
        $("#fbot").removeClass("fboto");
    });
});
});



</script>

现在我想要的是将 fadeIn 和 fadeOut 添加到不断变化的背景中,但是我不确定正确的方法,我尝试了一些不同的安排,但它的工作方式只是不按照我想要的方向或顺序..

我的那些div的html:

<div id="fbox">
<div id="ftop"></div> <!-- top of fullbox -->



<!-- middle of fullbox -->
<div id="fmid">
<!-- content for the fullbox goes BELOW here -->


<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />


<!-- content for the fullbox goes ABOVE here -->
</div>
<!-- end middle of fullbox -->



<div id="fbot" class="fbot"></div> <!-- bottom of fullbox -->

</div>

我用于更改背景图像的简单css..:

.fboto {
  width: 934px;
  background:url(images/cb/fboto.png) no-repeat;
  height: 17px;
  margin:0
 }

任何帮助会很好,谢谢!

Alrighty so here's my current jquery code which on hover of div "fbox" replaces a background by changing the class for the div "fbot"

    <script>
 $(document).ready(function () {
$(function() {
     $("#fbox").hover(function () {
        $("#fbot").addClass("fboto");
    },
    function () {
        $("#fbot").removeClass("fboto");
    });
});
});



</script>

Now what I want is to add fadeIn and fadeOut to the changing background however I'm not sure of the proper way to do it, I've tried some different arrangements of it and it worked just not in the direction or order I wanted it to..

My html for those div's:

<div id="fbox">
<div id="ftop"></div> <!-- top of fullbox -->



<!-- middle of fullbox -->
<div id="fmid">
<!-- content for the fullbox goes BELOW here -->


<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />


<!-- content for the fullbox goes ABOVE here -->
</div>
<!-- end middle of fullbox -->



<div id="fbot" class="fbot"></div> <!-- bottom of fullbox -->

</div>

My simple css for the background image to change.. :

.fboto {
  width: 934px;
  background:url(images/cb/fboto.png) no-repeat;
  height: 17px;
  margin:0
 }

Any help would be great, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半步萧音过轻尘 2024-10-14 21:06:25

jQuery UI 允许您以动画方式添加和删除类。只需包含 jQuery UI 的插件,您就可以执行以下操作:

$("#fbot").addClass("fboto",duration,callBack);
$("#fbot").removeClass("fboto",duration,callBack);

如需进一步参考: jQuery UI addClass

jQuery UI allows you to animate adding and removal of classes. Simply by including jQuery UI's plugin you can do:

$("#fbot").addClass("fboto",duration,callBack);
$("#fbot").removeClass("fboto",duration,callBack);

For further reference : jQuery UI addClass

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文