javascript - Scrolltop animation locking scroll -
i have form multiple fields. in each field, page scroll bottom
$('.my_input').on('change', function(e){ $("html, body").animate({ scrolltop: $("html, body").height()}, "slow"); }
this works fine, if try scroll top, page "freeze" scroll in bottom, releasing after several attemps.
how fix it?
tks
maybe event firing again , again. can try using one
fire event once.
see code below. please share sufficient code replicate problem, if doesn't maybe reason problem.
$(document).ready(function(){ $('.my_input').one('change', function(e){ $("html, body").animate({ scrolltop: $("html, body").height()}, "slow"); }); });
.my_input{ display:block; margin-bottom:300px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="text" class="my_input"/> <input type="text" class="my_input"/> <input type="text" class="my_input"/>
Comments
Post a Comment