Here is a menu in which 2 lists (length and width) are hidden in the initial position, but they open when you click on them and when you click on the link of the selected item - they close to the default position (works out $ ("ul"). Hide ( );). How to make, that at transition the openness or closeness of the menu was transferred in js code?
Here is a link to jsfiddle (for general presentation): http://jsfiddle.net/Alexboo/nh3jutfb/3/
Css file:
.box { width: 250px; border: 1px solid #d1d1d1; } h3 { font-size: 13px; cursor: pointer; } h3 span { float: right; cursor: pointer; } .line { height: 2px; background-color: lightgrey; } Html file:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="box"> <h3>Длина:<span class="expand">+</span></h3> <ul> <li><a href="..."></a>1 метр</li> <li><a href="..."></a>2 метра</li> <li><a href="..."></a>3 метра</li> </ul> <div class="line"></div> <h3>Ширина:<span class="expand">+</span></h3> <ul> <li><a href="..."></a>1 метр</li> <li><a href="..."></a>2 метра</li> <li><a href="..."></a>3 метра</li> </ul> </div> <script> $(document).ready(function(){ $("ul").hide(); // Эта строка прячет список $(".box h3").click(function(){ $(this).next().slideToggle(); var text = $("span",this).text(); $("span",this).text(text != "+" ? "+" : "-") }); }); </script>