jQuery 幻灯片切换

发布于 2024-10-18 17:50:09 字数 338 浏览 7 评论 0原文

我有这个 jquery 代码,它显示我的 div 并隐藏它,没有问题,但我在将其从 css 显示更改为 SlideToggle 显示时遇到问题?

$('li.trigger').hover(
        function() { $(this).css('background-color', '#fff'); $('div', this).css('display', 'block'); },
        function() { $(this).css('background-color', '#fff'); $('div', this).css('display', 'none'); });

I have this jquery code which displays my div and hides it no problem but im having trouble changing it from css display to slideToggle display?

$('li.trigger').hover(
        function() { $(this).css('background-color', '#fff'); $('div', this).css('display', 'block'); },
        function() { $(this).css('background-color', '#fff'); $('div', this).css('display', 'none'); });

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

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

发布评论

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

评论(3

帅哥哥的热头脑 2024-10-25 17:50:09

尝试一下,如果您不需要滑动 div,那么只需将 .slideUp() 移动到与 slideDown 相同的上面一行

$('li.trigger').hover(
        function() { 
            $(this).css('background-color', '#fff'); 
            $('div', this).css('display', 'block').slideUp(); 
        },
        function() { 
            $(this).css('background-color', '#fff'); 
            $('div', this).css('display', 'none').slideDown(); 
         });

Give this a go, if u dnt need to slide the divs then just move .slideUp() to the line above same with slideDown

$('li.trigger').hover(
        function() { 
            $(this).css('background-color', '#fff'); 
            $('div', this).css('display', 'block').slideUp(); 
        },
        function() { 
            $(this).css('background-color', '#fff'); 
            $('div', this).css('display', 'none').slideDown(); 
         });
三生殊途 2024-10-25 17:50:09
$('li.trigger').hover(
        function() { $(this).css('background-color', '#0099ff');
 $('div', this).css('display', 'block').slideToggle("slow"); 

});
$('li.trigger').hover(
        function() { $(this).css('background-color', '#0099ff');
 $('div', this).css('display', 'block').slideToggle("slow"); 

});
傲影 2024-10-25 17:50:09

这是有效的

$('li.trigger').hover(
    function() { $(this).css('background-color', '#fff');$('div', this).slideToggle("slow"); 
});

Heres what worked

$('li.trigger').hover(
    function() { $(this).css('background-color', '#fff');$('div', this).slideToggle("slow"); 
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文