Try this :
<script type="text/javascript">
$(document).ready(function($) {
$('#access li').has('ul').addClass('has_submenu');
$('#access ul li.has_submenu > a').click(function(event) {
event.preventDefault();
$("#access ul ul").toggleClass("showHide");
});
});
</script>
See event.preventDefault in the jQuery API.
Related Posts:
- add JS to multiple plugin admin pages
- Remove wrapping div and ul from output of wp_nav_menu
- How to make a script load after Custom Block is loaded in the editor?
- Add custom html to last sub-menu item
- wp_nav_menu() custom container and container_id
- global menus made from master site’s custom menus wpmu network
- Adding Custom Link anchors in the top menu that points to specific sections of the site home page
- When using the block.getSaveElement hook can you output different markup based on whether or not you are in the edit view or the live page view?
- wordpress custom walker for thumbnails with custom menu
- Change default status and replace the icon for an hamburger menu
- Create a Custom menu item fetched by Product Categories and Sub Categories
- wp_nav_menu google analytics event tracking
- Only append custom classes to nav menu items
- How to use get_option() without any filter?
- dynamic external javascript generated using php
- How to extend nav-menu-item-control data in Appearance > Customize?
- Hide Login information in Account settings in Buddy Boss
- How can I get the page url slug when ‘post_name’ returns an id?
- How to link external JavaScript files?
- Adding all sub-pages to the menu manager
- Create simple Cookie Box for WordPress
- Putting tag outside tag on generated Menu
- how to add custom css and js on wordpress post editor directly without using .php file
- Programmatically (PHP) get the nr. of items in the primary navigation menu
- Javascript Solution Remove Specific Tag but leave the rest in a specific DIV
- window resizing problem
- How to create left and right menu with logo center in a custom theme?
- Add clickable arrows to parent menu items with children elements e.g. with
- How Do I Remove The Right Hand Block On The Main Header?
- Load MediaPlayerElement after Infinity Scroll loads more posts
- Adding posts to custom menu [closed]
- Include custom JS without child theme
- How to wrap the list with custom class using wp_nav_menu?
- Alphabetical Custom Menu
- Sub menu indicator that links to sub menu
- Navigation label for page in custom theme
- Redirect to another page using contact form 7? [closed]
- how to display a specific wordpress menu?
- Custom Login Process
- Create a url structure for my blogs based on categories and sub-cats
- Sticky menu for WP custom menubars
- Stop Expansion of Top Level Menu in the WordPress Admin Sidebar
- Implement a Walker with custom object rather than WordPress database object
- How can I tag a menu item as visited for each unique user?
- How do I create a root link in wordpress to a PDF file?
- Upload a web module (html and JS) to wordpress
- How can i create menu like in the example?
- WordPress custom dropdown listings
- How to request container_class from wp_nav_menu
- Menu not appearing in custom theme
- How can i display custom menu in sidebar?
- How to have multiple WordPress Menus
- How to add active state to the navigation links?
- How to add WordPress JS Script Links
- custom css and javascript not working on page defined as template?
- Missing current_page_item in custom menu
- WordPress menu: How to make www.link.com/#name never contain current_page_item class?
- Customize Widget Navigation
- wp_enqueue_script JS code runs too late (after user begins interacting)
- Custom menu not showing even though it shows as being registered?
- Custom CSS Nav Menu Style Not Being Applied
- javascript file not working in a plugin template file
- Current menu item highlights wrong
- Add producthunt badge to wordpress menu
- Woocommerce custom “My Account” Tab – Add Save button
- Adding a drop-down (select tag) option under Menu Settings in WordPress Admin
- How to add a template – so that i can choose a different menu for some pages
- Javascript Tooltip not fully working on my wordpress page
- clickable toggle menu, help
- Where to put coding a validation script for store? [duplicate]
- WordPress Customizer: Check for value of CSS selector and replace it
- Help needed creating a custom Hamburger menu in header
- Menu selection for header
- How to create a custom menu for specific user
- How to submit form data in the same page in WordPress without reloading the page?
- How to customize WordPress vertical menu?
- Creating a dynamic URL for an external link inside content
- remove or hide Link Relationship (XFN) form Menus tab
- My connecting URL form in html to PHP does not work
- User WordPress menu in custom page
- how to auto fille conatct form 7 when user is logined
- Adding images to anchors in the list created and fetched with wp_nav_menu
- How to implement custom Javascript to my site
- Multi-site customization
- how to hard link to the posts page?
- How do I display entries in the top menu based on conditions selected in the sidebar menu?
- How to work around the bug which prevents custom menus from being deleted?
- Class .current-menu-item in custom menu Walker
- Pass the post ID
- Document.body.scrollTop in WordPress
- menu customization
- How to move menu next to left of the search box?
- Adding Custom HTML/CSS/JS code in specific page
- Making custom pages (with an example to explain the goal)
- Custom CSS File wont work on second Page
- removing extra mobile menu from the header
- Prevent posts from being published if the ‘Uncategorized’-category or no category is selected
- Particle.js not loading in WordPress Gutenberg
- Custom Menu (only showing direct cildren) ACF not showing
- Multi color post title by using custom javascript inside the gutenberg editor?