tags:

views:

28

answers:

3

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 .

+2  A: 

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();
});
Matt
+1  A: 

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.

Jeriko
you know exactly what I'm doing :)Thanks so much guy :)
nXqd
+2  A: 

OR <a href="javascript:;" class="toggle_this" >hello world!</a>

e.preventDefault() as Matt say is good one of course!

aSeptik