3 ms·
Yeah, in the days where fixed nav at top is often used by default it is not as common to have TOP links any more. Recently I searched for a way to PREVENT going
by sandreas 5y ago
Yeah, in the days where fixed nav at top is often used by default it is not as common to have TOP links any more. Recently I searched for a way to PREVENT going to the top clicking a link <a href="#" onclick="console.log(1)"> that only had JavaScript in it and always jumped back and forth due to AJAX page reload.
The solution[1] I found was using <a href="#!" onclick="console.log(1)">A no jump link</a>.
[1]https://pilabor.com/blog/2021/03/html-and-css-tricks/#no-jump-links-href https://pilabor.com/blog/2021/03/html-and-css-tricks/#no-jum...
- JadedBlueEyes 5y agoOn a slight tangent, links should not be used as buttons - please use a HTML button and style it with css. Links-as-buttons tend to interact poorly with things like opening in new tabs, and it's not the semantically correct use of the element anyway. > If clicking the link without javascript doesn't do anything without Javascript, it should be a `button` https://css-tricks.com/a-complete-guide-to-links-and-buttons/#buttons https://css-tricks.com/a-complete-guide-to-links-and-buttons...
- 8n4vidtmkvmk 5y agoYou can make the onclick event.preventDefault to prevent the scroll and adding hashtag to the URL