I am trying to create a simple expandable menu in wordpress.
Bellow you can see the javascript I am using (copy and mix from internet).
<script type="text/javascript">
$(document).ready(function($) {
$('#access li').has('ul').addClass('has_submenu');
$('#access ul li.has_submenu a').click(function() {
$("#access ul ul").toggleClass("showHide");
});
});
</script>
The first part is ok, script adds has_submenu class to my menu.
Second part should toggle showHide class.
My problem is that when I click the showHide class appears but dissapears right after(page reloads).
Thanx for help 🙂
Try this :
See event.preventDefault in the jQuery API.