1

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

Roland Jegorov
  • 789
  • 1
  • 11
  • 27

3 Answers3

1

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

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

 });
0

View Live jsFiddle

j- Query

$(document).ready(function () {
    $("li").click(function () {
        $(this).children().children().toggle();
    });
});
Community
  • 1
  • 1
Jaykumar Patel
  • 26,836
  • 12
  • 74
  • 76
  • jquery method to archive this easily. Drop-down menu number of different way to create but in your code no need to modification it's ok. – Jaykumar Patel Nov 11 '14 at 11:13
0

issue is in javascript plz check below code

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

      }); 
jithender
  • 50
  • 2