jquery accordition page jumps after completion of accordition
-
hi, i have a jquery horizontal accordition menu with code something like this // Hide the old content old.slideToggle(500); // Show the new content cur.stop().slideToggle(500); But when the slideToggle function executes and shows new content, the page jumps to top. how to solve this problem? when i have searched in google i have found that it is problem with css height:auto etc, but i have not found a solution. thanks
-
hi, i have a jquery horizontal accordition menu with code something like this // Hide the old content old.slideToggle(500); // Show the new content cur.stop().slideToggle(500); But when the slideToggle function executes and shows new content, the page jumps to top. how to solve this problem? when i have searched in google i have found that it is problem with css height:auto etc, but i have not found a solution. thanks
I guess you would have used anchors <a href="#">Link</a> in accordions to open the panel. This is making your page to jump to top. The solution can be in different ways. You can write like <a href="javascript:void(0)">Link</a> Or, you can remove the href and keep the <a> only, but in this case you need to set different styles which are default to anchor tags explicitely. Or, you can use event.preventDefault() inside the handler for that link. I hope I am making a right guess. Thanks
-
I guess you would have used anchors <a href="#">Link</a> in accordions to open the panel. This is making your page to jump to top. The solution can be in different ways. You can write like <a href="javascript:void(0)">Link</a> Or, you can remove the href and keep the <a> only, but in this case you need to set different styles which are default to anchor tags explicitely. Or, you can use event.preventDefault() inside the handler for that link. I hope I am making a right guess. Thanks
correct solution to this problem thanks
-
hi, i have a jquery horizontal accordition menu with code something like this // Hide the old content old.slideToggle(500); // Show the new content cur.stop().slideToggle(500); But when the slideToggle function executes and shows new content, the page jumps to top. how to solve this problem? when i have searched in google i have found that it is problem with css height:auto etc, but i have not found a solution. thanks
add
return false;
at last of your javascript function you don't provide much more detail but this could solve your problem also add id of element instead
cur.stop().slideToggle(500);
use
cur.stop().slideToggle("id");