views:

389

answers:

2

I have a webpage with multiple DIV elements. If i use the jquery function SlideUp to hide one (which is towards the bottom of the page), the page automatically scrolls back to the top. How can I prevent this?

To trigger the jquery function, I do something like this:

$(MyLink).click(function() {
MyDiv.slideUp("slow");
}
MyLink being within MyDiv which is somewhere in the middle of the page.

+3  A: 

How do you trigger the jquery function, via anchors? If so, have the function return false, otherwise the browser will redirect to the href-attribute, which would be '#' in this case.

To trigger the jquery function, I do something like this:$(MyLink).click(function() {MyDiv.SlideUp} MyLink being within MyDiv
Anthony
A: 

What I did was what someone suggested (adding 'return false') and it worked:

$(MyLink).click(function() {
MyDiv.slideUp("slow");
return false;
}

Anthony