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 way to do this is by adding tabindex="-1" . By adding this to a specific element, it becomes unreachable by the keyboard navigation.
In order to disable a HTML Anchor Link (HyperLink), the value of its HREF attribute is copied to the REL attribute and the value of HREF attribute is set to an empty JavaScript function. This makes the HTML Anchor Link (HyperLink) disabled i.e. non-clickable.
To prevent tab indexing on specific elements, you can use tabindex="-1". If the value is negative, the user agent will set the tabindex focus flag of the element, but the element should not be reachable with sequential focus navigation. Note that this is an HTML5 feature and may not work with old browsers.
Some browsers support the tabindex="-1"
attribute, but not all of them, since this is not a standard behaviour.
Modern, HTML5 compliant, browsers support the [tabindex]
attribute, where a value of -1
will prevent the element from being tabbed to.
If the value is a negative integer
The user agent must allow the element to be focused, but should not allow the element to be reached using sequential focus navigation.
You could apply a JQuery handler to the element you want to target multiple elements with no tab stop.
$(document).ready(function () {
$('.class').attr('tabindex', '-1');
});
Would be one way to do it....
I think you could do this by javascript, you override the window.onkeypress
or onkeydown
, trap the tab button, and set the focus at the desired order.
Remove the href
attribute from your anchor tag
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