Here an example of my code.
$("#slideshow img").on("click", function (e) {
$(".fullimage").hide();
var next = $(this).next();
if (next.length > 0) {
next.fadeIn(1000);
} else {
$("#slideshow img:first-child").fadeIn(1000);
}
e.preventDefault();
});
When the image fadeIn() my page jump to top, if I change fadeIn() to show() it working fine. Let me know what it cause.
Presumably something of the following is going on
A: Something breaks in the
fadeInscenario, so thate.preventDefault()never occurs, and the default action might here be to follow a link, to#say, which would give the appearance of jumping to the top of the page.B: The element being faded being in itself a major cause for the page having scroll in the first place, and by absolutely positioning it during fade, the page loses scroll height.
Originally posted as comment but migrated to an answer upon request from OP