在 bootstrap 模态中更改 scrollTop()
change scrollTop() in bootstrap modal
在 bootstrap 模式中,当我在底部添加新表单时,我想将我的 scrollTop()
从它的位置移动,即可能是 "0"
,到 100px
,当我点击 ajax Link 它显示了一个表格,在执行显示表格的代码后,我输入了代码:
$('html, body').animate({ scrollTop: 100 });
我认为它应该像我希望的那样工作,但它没有。我还将代码作为函数 scrollDown(n) 放在父页面中,并在 Ajax 中显示代码的表单之后调用该函数。但还是没有运气....
我不知道我做错了什么?
不胜感激。谢谢
编辑:
此代码显示模态中的电子邮件表单,它实际上改变了模态高度,我想将滚动条移动到 apx: 100px 从顶部向下。
显示表格的代码是:
function showEmailBox(person_sno,fir_sno,divFrm){
try{
$("#"+divFrm).show();
$("#"+divFrm).removeClass("animated rubberBand");
$("#"+divFrm).load("../ajaxPhp/emailReminderForm.php",{person_sno:person_sno,fir_sno:fir_sno,divFrm:divFrm},function(txt,status,xhr){
if(xhr.statusText == 'OK'){
$(this).html(txt).addClass("animated rubberBand");
}
else{
$(this).html('Error: - '+ xhr.status+' '+xhr.statusText).addClass('text-danger');
}
});
}catch(e){
alert(e.message);
}
setTimeout(function(){
$(this).removeClass("animated rubberBand");
},500);
$('html, body').animate({ scrollTop: 100 });
}
这里是最后一行
$('html, body').animate({ scrollTop: 100 });
这条线路不行?
我找到了相同问题的解决方案。
您可以为此设置 scrollTop
0px,
$('html, body').animate({scrollTop : '0px'}, 0);
希望对您有所帮助。
在 bootstrap 模式中,当我在底部添加新表单时,我想将我的 scrollTop()
从它的位置移动,即可能是 "0"
,到 100px
,当我点击 ajax Link 它显示了一个表格,在执行显示表格的代码后,我输入了代码:
$('html, body').animate({ scrollTop: 100 });
我认为它应该像我希望的那样工作,但它没有。我还将代码作为函数 scrollDown(n) 放在父页面中,并在 Ajax 中显示代码的表单之后调用该函数。但还是没有运气.... 我不知道我做错了什么?
不胜感激。谢谢
编辑: 此代码显示模态中的电子邮件表单,它实际上改变了模态高度,我想将滚动条移动到 apx: 100px 从顶部向下。 显示表格的代码是:
function showEmailBox(person_sno,fir_sno,divFrm){
try{
$("#"+divFrm).show();
$("#"+divFrm).removeClass("animated rubberBand");
$("#"+divFrm).load("../ajaxPhp/emailReminderForm.php",{person_sno:person_sno,fir_sno:fir_sno,divFrm:divFrm},function(txt,status,xhr){
if(xhr.statusText == 'OK'){
$(this).html(txt).addClass("animated rubberBand");
}
else{
$(this).html('Error: - '+ xhr.status+' '+xhr.statusText).addClass('text-danger');
}
});
}catch(e){
alert(e.message);
}
setTimeout(function(){
$(this).removeClass("animated rubberBand");
},500);
$('html, body').animate({ scrollTop: 100 });
}
这里是最后一行
$('html, body').animate({ scrollTop: 100 });
这条线路不行?
我找到了相同问题的解决方案。
您可以为此设置 scrollTop
0px,
$('html, body').animate({scrollTop : '0px'}, 0);
希望对您有所帮助。