简体   繁体   中英

JavaScript menu dropdown onClick does not work

I am trying to make the drop down menu toggle on click but the JavaScript does not work with this html and css, while it works in other projects. The drop down enabled on hover before but I deleted ...: hover {display: block;}

Rest of the code in CodePen --> http://codepen.io/anon/pen/bNbzjM

HTML

 <li id="active"><a href="#">УСЛУГИ</a>
                <div id="block_menu">
                <ul class="pod_nav1">
                    <li><a href="#">SEO Pakalpojumi</a></li>
                </ul>
                <ul class="pod_nav2">
                    <li><a href="#">SEO Pakalpojumi</a></li>
                </ul>
                <ul class="pod_nav3">
                    <li><a href="#">SEO Pakalpojumi</a></li>
                </ul>
                <ul class="pod_nav4">
                    <li><a href="#">SEO Pakalpojumi</a></li>
                </ul>
                </div>
 </li>

JavaScript

    $(document).ready(function () {
        $("li").click(function () {
            $('li > ul ').not($(this).children("ul").toggle()).hide();

        });
    });     

CSS

may be this will help. don't forget to include jquery.js

$("li").on('click',function() {
     $('li > ul ').not($(this).children("ul").toggle()).hide();

 });

View Live jsFiddle

j- Query

$(document).ready(function () {
    $("li").click(function () {
        $(this).children().children().toggle();
    });
});

issue is in javascript plz check below code

 $(document).ready(function () { $("li").click(function () { $(this).find('#dropmenu').children('ul').toggle('slow'); }); }); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM