I have a div set to toggle hide/show onClick. I currently have it set to trigger a chat feature but when someone clicks it, it brings them back to the very top of the page, or resets the position of where they last where. How can I stop this from happening easily ? Thank you!
SOLUTION: Thank you to everyone who contributed! While all the answers worked, I ended up just removing the href=”#” like everyone said since it was the most simplest method. Thanks again guys!
Usually this is because you have
href="#"or something and it is actually going to this anchor and not finding it.So what you should do is
return false;in your onclick handler. That will prevent the click processing from continuing, thus preventing the browser from navigating to your nonexistent anchor.