下面显示的是我的 HTML 代码,它是一个 Bootstrap 模式弹出窗口。我想做的是,如果用户单击“保存”按钮,我正在执行某种验证,如果验证失败,则会显示该消息,并且应自动向上滚动到模式弹出窗口的顶部。但它不向上滚动。下面我还指出了 JS 文件中的代码。
<div id="addD" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="addPatientLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="addLabel">Create</h3>
</div>
<div class="modal-body">
<p class="validateTips"></p>
<table>
<tr>
<td class="TemplateLabel">
Name:
</td>
<td align="left">
<input placeholder="name" type="text" name="Name" data-bind="value: NewP.Name" id="SignUpName" class="SignUp text ui-widget-content ui-corner-all" />
</td>
</tr>
</table>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary" onclick="SaveD()">Save changes</button>
</div>
</div>
在我的 JS 文件中:
function SaveD() {
debugger;
var bValid = true;
bValid = bValid && CheckRequired($('#SignUpName'));
if (bValid) {
/*Some func called*/
}
else
{
$('#addD-content').scrollTop(0);
}
}
有什么帮助吗?基本上$('#addD-content').scrollTop(0);
不管用。
$('#addD').animate({ scrollTop: 0 }, 'slow');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)