0
When I click on an anchor like <a href="#um_id">clique aqui</a>
, that has a #ID on href, it defaults to move up to the part that has this id as a bookmark.
How I would discount this behavior?
0
When I click on an anchor like <a href="#um_id">clique aqui</a>
, that has a #ID on href, it defaults to move up to the part that has this id as a bookmark.
How I would discount this behavior?
0
You can disable the standard anchor action (either for the document itself or a normal link) in two ways. My examples will affect all the page anchors, it’s up to you to adapt the selectors to your need.
a { pointer-events: none; }
https://jsfiddle.net/bfavaretto/yu7rL2n4/
const stopClick = (e) => e.preventDefault()
document.querySelectorAll('a').forEach( a => a.addEventListener('click', stopClick, false));
Browser other questions tagged html css
You are not signed in. Login or sign up in order to post.
And what do you intend to do at the anchor click? Anchors were made for navigation, if the idea is to perform some function javascript in the click, use a button and, by default, will not have the problem cited.
– Woss
Do you want to break the anchor? Just put an id that doesn’t exist on the link href, like #! For example, or remove the id of the html tag from the element. your question was not very clear.
– hugocsl