0

how to prevent dropdown menu close on menu item click. I tried to do something but it does not work.

<script>
// Do not close dropdown on menu item click
$(document).on('click', '.list-dropdown', function (e) {
    e.stopPropagation();
});

Fixed with line: onclick="event.stopPropagation();"

2 Answers2

0

Use this where you have e.stopPropagation:

e.preventDefault();
return true;
Chris Halcrow
  • 28,994
  • 18
  • 176
  • 206
0

Stop propagation prevents the event from propagating to other methods. But what you are looking to do here, is stop the default behaviour (which is close the menu).

Your code should look like the following:

<script>
// Do not close dropdown on menu item click
$(document).on('click', '.list-dropdown', function (e) {
    e.preventDefault();
});
</script>
amilete
  • 106
  • 3