开发者

jQuery slideToggle

开发者 https://www.devze.com 2023-02-13 09:22 出处:网络
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?

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?

$('l开发者_运维技巧i.trigger').hover(
        function() { $(this).css('background-color', '#fff'); $('div', this).css('display', 'block'); },
        function() { $(this).css('background-color', '#fff'); $('div', this).css('display', 'none'); });


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(); 
         });


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

});


Heres what worked

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

精彩评论

暂无评论...
验证码 换一张
取 消