Jquery hide not working (NOT IE)

jQuery is driving me crazy. Ive looked around the web for a simple category expander slider, but didn't find it. Ive tried to create it here.

The problem I am facing is trying to hide the () element previously shown () n. If there is another show () n element before the hide () call, the hide () call for the first element is ignored!

Forgive me for posting the full HTML (please feel free to suggest where I will have to contain all the code samples in the future).

If anyone has suggestions for a jQuery plugin or other implementation of what I'm trying to do, point me in that direction - I'm glad to use something already done.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
        <script type="text/javascript">
            $().ready(function() {
                $("ul.box_li li.parent").mouseenter(function(event){
                    event.stopPropagation();
                    $(this).children("ul:first").show('slide',{direction: 'left'});
                }).mouseleave(function(event){
                    event.stopPropagation();
                    $(this).children("ul:first").hide('slide',{direction: 'left'});
                });
            });
        </script>
        <style type="text/css">
            body {font-size:10pt;}
            ul.box_li li.parent {position:relative;}
            ul.box_li li {background-color:#e6e6e6;width:200px;border:1px solid red;list-style-type:none;padding:5px;}
            ul.box_li>li ul {display: none;position: absolute;top: 0;left: 100%;}
        </style>
    </head>
    <body>
        <ul class="box_li">
            <li class="parent">
                FIRST
                <ul>
                    <li class="parent">
                        FIRST_SUB_1
                        <ul>
                            <li>FIRST_SUB_1_SUB_1</li>
                            <li>FIRST_SUB_1_SUB_2</li>
                            <li>FIRST_SUB_1_SUB_3</li>
                            <li>FIRST_SUB_1_SUB_4</li>
                        </ul>
                    </li>
                    <li>FIRST_SUB_2</li>
                </ul>
            </li>
            <li class="parent">
                SECOND
                <ul>
                    <li>SECOND_SUB_1</li>
                    <li>SECOND_SUB_2</li>
                    <li>SECOND_SUB_3</li>
                    <li>SECOND_SUB_4</li>
                    <li>SECOND_SUB_5</li>
                    <li>SECOND_SUB_6</li>
                    <li>SECOND_SUB_7</li>
                    <li>SECOND_SUB_8</li>
                </ul>
            </li>
            <li class="parent">
                THIRD
            </li>
            <li class="parent">
                FOURTH
                <ul>
                    <li>FOURTH_SUB_1</li>
                    <li>FOURTH_SUB_2</li>
                    <li>FOURTH_SUB_3</li>
                    <li>FOURTH_SUB_4</li>
                    <li>FOURTH_SUB_5</li>
                    <li>FOURTH_SUB_6</li>
                    <li>FOURTH_SUB_7</li>
                    <li>FOURTH_SUB_8</li>
                </ul>
            </li>
            <li class="parent">
                FIFTH
                <ul>
                    <li>FIFTH_SUB_1</li>
                    <li>FIFTH_SUB_2</li>
                    <li>FIFTH_SUB_3</li>
                    <li>FIFTH_SUB_4</li>
                    <li>FIFTH_SUB_5</li>
                    <li>FIFTH_SUB_6</li>
                </ul>
            </li>
        </ul>
    </body>
</html>
+3
1

, , , :

$("ul.box_li li.parent").hover(function(){
    $(this).children("ul:first").animate({ width: 'toggle'});
});​

, - , jQuery UI , , slide:

el.animate(animation, { queue: false, ....

fx, , , ... , . , , . , ..... , .stop() .

+3

Source: https://habr.com/ru/post/1751176/


All Articles