yep*_*ppe 1 html javascript jquery
代码无效
$(document).ready(function() {
if the action is successful and returns a success message then Only{
document.getElementById("tabledataid_row").focus();
}
});
Run Code Online (Sandbox Code Playgroud)
表数据内容
<table>
<tr>
<td id="tabledataid_row"></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我希望<td>在提交页面后将焦点放回到表格数据中.例如,在Struts操作中,提交将表单返回到屏幕顶部.我尝试使用JavaScript方法focus(),它适用于textfield或输入类型的元素.
但是当我为<td>元素分配一个id 然后以onload/document ready形式将其拾取然后像上面那样调用focus()时,它就不起作用了.
请注意,我已经在各个地方插入了tabindex,这个元素id有tabindex 4.所以,我不想更改tabindex以获得焦点来到id.只有可视页面以所需字段可见的方式移动.
你只能专注于input元素.你想要做的是确保id在视图中.您可以使用,实现您想要做的事情('专注于HTML元素')scrollIntoView().
document.getElementById("tabledataid_row").scrollIntoView();