On click slidetoggle h4 but hide other ul close first
Hello,
I have two lists. Now if you open one list the other doesn't close.
How can I make: if you click on one h4 the other list close.
How can I make this?
thanks in advance
the code is:
- <!DOCTYPE HTML>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title></title>
- <style>ul{display: none;}</style>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
- <script>
- $(document).ready(function(){
- $(".flip").click(function(){
-
- $(this).next('ul').slideToggle();
- $(this).parent('ul').siblings().slideUp();
- return false;
-
- });
- });
- </script>
- </head>
- <body>
- <h4 class="flip">Click</h4>
- <ul>
- <li>A</li>
- <li>B</li>
- <li>C</li>
- </ul>
- <h4 class="flip">Click</h4>
- <ul>
- <li>D</li>
- <li>E</li>
- <li>F</li>
- </ul>
- </body>
- </html>