This is not an element that needs .preventDefault()
, its event
click.
Try the following:
$('nav.menu a').click(function (event) { event.preventDefault();
I do not recommend using href
as a selector, but it's better to give it id
or name
.
From MDN, about.preventDefault ():
Cancels an event if it is canceled without stopping the further distribution of the event.
You can read here:
Thus, using CSS pointer-events: none;
, all clicks will be ignored. This is a "recent" alternative and is supported in IE11 +, Firefox 3.6+, Chrome 2.0+, Safari 4+.
source share