我试图将焦点放在调用 .show() 函数后显示的隐藏 div 上。我尝试了一些方法,包括 show().focus() 或将其拆分为
$(".messageDisplayArea").show();
$("#message_display_area").focus();
div 出现了,但页面没有将焦点转移到它。
<script>
function showMessage(id, row) {
selectRow(row);
$(".messageDisplayArea").show();
$("#message_display_area").focus();
}
</script>
<div class="messageDisplayArea" id="message_display_area" style="display: none;">
<p> Test Test Test </p>
</div>
我错过了什么?它所在的页面相当大,div 出现在页面底部。我想让浏览器跳下来,把新的div放在焦点上
最佳答案
替换这一行:
$("#message_display_area").focus();
用这一行:
window.location.hash = "message_display_area";
关于javascript - 放映后将焦点设置到 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17531458/