Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.slideToggle hover on div jquery [duplicate]

I want to be able to slideToggle a div on hover, but it is not working.. Here is the code:

<div class='slide-header'>
        header....
</div>

<div class='slide-content'>
       Content..................
</div>

<script>
$(".slide-header").hover(function () {
    $(".slide-content").slideToggle("slow");
});
</script>

<style><!-- initially, I don't want to display .slide-content -->
    .slide-content { display:none; }
</style>

How can I .slideToggle on hover? Thanks!

like image 351
Nick B Avatar asked Nov 24 '25 03:11

Nick B


2 Answers

Try this

$(".slide-header").hover(function () {
    $(".slide-content").stop().slideDown("slow");
}, function(){
    $(".slide-content").stop().slideUp("slow");
});
like image 162
Sushanth -- Avatar answered Nov 25 '25 17:11

Sushanth --


Wrap it in a document ready function:

$(function(){
    $(".slide-header").hover(function () {
        $(".slide-content").slideToggle("slow");
    });
});
like image 28
indot_brad Avatar answered Nov 25 '25 16:11

indot_brad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!