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

3 Answers 3

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();

 });
Sign up to request clarification or add additional context in comments.

Comments

0

View Live jsFiddle

j- Query

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

1 Comment

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.
0

issue is in javascript plz check below code

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

      });	

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.