Roland Jegorov
Roland Jegorov

Reputation: 819

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

Upvotes: 1

Views: 574

Answers (3)

jithender
jithender

Reputation: 60

issue is in javascript plz check below code

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

      });	

Upvotes: 0

Jaykumar Patel
Jaykumar Patel

Reputation: 27614

View Live jsFiddle

j- Query

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

Upvotes: 0

Bhaskor Jyoti Sarmah
Bhaskor Jyoti Sarmah

Reputation: 126

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

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

 });

Upvotes: 1

Related Questions