0

I'm trying to create a collapsed menu, but the menu should open by clicking on the arrow.

arrow in tag a, how to stop following a link, if click on the arrow?

<ul id="menu_0" class="nav nav-stacked">
<li><a href="http://example.org">item<span class="pull-right"><i class="glyphicon glyphicon-chevron-left" type="button" data-parent="#menu_0" data-toggle="collapse" data-target="#menu_submenu_1"></i></span></a>
    <ul id="menu_submenu_1" class="nav nav-stacked collapse">
        <li><a href="http://example.org">subitem 1</a></li>
        <li><a href="http://example.org">subitem 2</a></li>
        <li><a href="http://example.org">subitem 3</a></li>
        <li><a href="http://example.org">subitem 4</a></li>
    </ul>
</li>
</ul>

i trying this, but no effects

$(function() {
    $('#menu_0 .pull-right').click(function(event){ event.stopPropagation();});
});
Josh Crozier
  • 233,099
  • 56
  • 391
  • 304

1 Answers1

1

Use event.preventDefault()

$(function() {
    $('#menu_0 .pull-right').click(function(event){ event.preventDefault();});
});

difference between preventDefault and stopPropagation

Community
  • 1
  • 1
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231