0
When performing the scroll, the function performs normally, but keeps repeating every time I continue with the mouse scroll. I’d like to know how to make it run only once.
I’m doing like this:
$(window).scroll(function () {
var scrollTop = $(document).scrollTop();
if (scrollTop >= 100) {
$("#box").animate(
{ margin:'50px 0 0 0' },
600
); // end animate
}
});
Try to change
$(window).scroll(function () {
for$(window).on('scroll',function () {
– Jorge.M
So the function executes and returns to its initial state. For example, it does the marginTop 50px and returns to 0. I need it to go to 50px and stay at 50.
– Neo
It was actually
on
and notone
.– Jorge.M
even with 'on', did not solve
– Neo
Post your complete code on jsfilder to make it easier for us to see what is happening.
– Jorge.M