Animating multiple elements inside another element

痴心易碎 提交于 2019-12-12 04:24:45

问题


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

回答1:


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

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


来源:https://stackoverflow.com/questions/21052164/animating-multiple-elements-inside-another-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!