I have created a vertical list menu which consist of certain menu items. On clicking any menu item, the list expands to show its inner sub menu items.
Also, when the page is loaded, one of the menu will expand automatically according to the page. I used jquery toggle for this and it is working fine.
Now I have placed collapse/expand arrow with this menu similar to those in jquery accordian and they toggle on click event.
My problem is that when page loads, one of the menu items collapse but the arrow does not collapse with it and when I click on that menu again to collapse/toggle back, the arrow starts to toggle.
The situation can be seen as, On loading window -
►Menu1
submenu
submenu
submenu
►Menu2
►Menu3
►Menu4
As you can see the arrow with the menu1 is not down.
My code till yet -
<ul>
<div class="option-heading">
<li onclick="menu()"> //menu is the vertical menu which shows up.
<a href="#" >
<div class="arrow-up">►</div>
<div style="display: none;" class="arrow-down">▼</div>
</a>
</li>
</div>
</ul>
<script>
$(document).ready(function() {
$(".option-heading").click(function(){
$(this).find(".arrow-up, .arrow-down").toggle();
});
});
I used .load, but it expands all the arrows at once.
All I want to know is the way to toggle a particular element on loading the window. Such that other elements does not get affected by it. Like the present situation is with the arrows. Whenever the load event is triggered it toggles all the arrows.