Switching layouts page jumping (improvement to script)

Posted by Ricardo Zea on Stack Overflow See other posts from Stack Overflow or by Ricardo Zea
Published on 2010-05-19T21:15:57Z Indexed on 2010/05/19 21:20 UTC
Read the original article Hit count: 240

Filed under:
|

Hello,

I'm using this script to switch layouts in a page:

$("span.switcher").click(function () {
$("span.switcher").toggleClass("swap"); /*!*/
$("ol.search-results").fadeOut("fast", function() {
$(this).fadeIn("fast").toggleClass("grid");
});

The script works fine, the problem I have is that if the switch view is down the page, the layout changes and then the page jumps back up.

If I add 'return false' right where you see the /* ! */ in the second line the script doesn't work.

Also, as you can see, I'm using < span > instead of < a > since I was told that using other element other than < a > would stop the page from jumping.

Any idea how to fix the jumping of the page?

Thanks.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about page-jump