I'm new to jquery, i write a simple snippetto toggle menu . But the problem is : when I scroll at the bot of page and click menu to toggle. It go top unexpectedly .
Thanks for reading .
You probably have <a href="#">TEXT</a>
as your link, right?
href="#"
will make the browser scroll up to the top, so add a return false
on click, so it looks like this:
<a href="#" onclick="return false">TEXT</a>
; alternatively you can return false
from your click function to prevent the default behaviour.
If the element is an anchor tag, capture the event object, and call the preventDefault() method; as shown below.
$('a#whatever').click(function (event) {
event.preventDefault();
});
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