0

Prevent anchor tags from reloading the page.

Please does anyone know how to prevent a page from reloading when a user clicks on an anchor tag. I tried using preventDefault() but it doesn't change the URL in the address bar.

19th Nov 2020, 5:41 AM
Prosper Emebo
Prosper Emebo - avatar
4 Respuestas
+ 1
Can I change the URL in the address bar when a user clicks a button
19th Nov 2020, 5:44 AM
Prosper Emebo
Prosper Emebo - avatar
+ 1
Not clear what do you want. anchor for the same page but different position, or totally different page? In 1st case, use id and #id In second case if you put href="#" it will not reload
19th Nov 2020, 6:15 AM
Shadoff
Shadoff - avatar
0
Thanks but I'm trying to change the URL in the address bar of the browser not the element. And I want I'm trying to make this happen when the user clicks a button.
19th Nov 2020, 6:04 AM
Prosper Emebo
Prosper Emebo - avatar
0
Trying to change the URL in the address bar dynamically
19th Nov 2020, 3:50 PM
Prosper Emebo
Prosper Emebo - avatar