I have a tabbed content box that when a tab is clicked, a '#div1' is appended to the end of my URL. Is there a way of preventing jQuery from doing this?
I still can't get it to work. I've made a fiddle...
http://jsfiddle.net/k6Ks8/
Disable HTML Anchor Tag with CSSThe best way to disable a link tag is by using the CSS property pointer-events: none; . When you apply pointer-events: none; to any element, all click events will be disabled. Because it applies to any element, you can use it to disable an anchor tag.
To disable a HTML anchor element with CSS, we can apply the pointer-events: none style. pointer-events: none will disable all click events on the anchor element. This is a great option when you only have access to class or style attributes. It can even be used to disable all the HTML links on a page.
How could you prevent a click on an anchor from going to the link? To prevent an anchor from visiting the specified href, you can call the Event interface's preventDefault() method on the anchor's click handle.
The anchor part is the part of the URL after the hash sign (#).
Sure, event.preventDefault()
is what you are looking for.
http://api.jquery.com/event.preventDefault/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With