Search code examples
jqueryjquery-animateslidedownslideup

Animating multiple elements inside another element


So I have container and inside there is yui library with 5 divs. This divs are menus. So what i want to do is that when I move mouse over div only this one will animate UP and when I move mouse somewhere else it will animate DOWN. My js code animate all elements at same time.

<div class="container">
<div class='yui3-g-r'>

    <div class="yui3-u-1-5">
        <div class="kvadrat">
            <span class="title"><a>Smeri</a></span><br/>
            <span class="description">
                <ul class="blabla">
                 <li><a class="link" href="smeri/racunalnistvo_prva/index.html" >Računalništvo</a></li>
                 <li><a class="link">Strojništvo</a></li>
                </ul>
            </span>
        </div>
    </div>

    <div class="yui3-u-1-5">
        <div class="kvadrat">
            <span class="title"><a>Galerija</a></span><br/>
            <span class="description">
                <ul class="blabla">
                    <li><a class="link" href="galerija/predstavitev poklicev-nak. center/osnova/index.html">Slike</a></li>
                </ul>
            </span>
        </div>
    </div>

And my jQuery code is this :

$(".description" ).hide();

$('div.kvadrat').hover(
     function () {
       $(".description" ).slideDown( "slow" );
     }, 
     function () {
        $(".description" ).slideUp( "slow" );
     }
 );

Solution

  • $(".description" ).hide();
    
    $('div.kvadrat').hover(
         function () {
           $(this).find(".description" ).slideDown( "slow" );
         }, 
         function () {
            $(this).find(".description" ).slideUp( "slow" );
         }
     );