我在使用Firefox浏览器时,尝试使用jQuery JavaScript将焦点设置到控件上遇到了问题。虽然我的具体问题相当复杂,但即使是下面的简单测试用例也不能解决我的问题。找到了输入框,改变了它的值,但是输入框没有获得焦点。
此问题仅出现在Firefox浏览器中。
在Windows 7上尝试了Firefox 44.0.2版本,但在MS IE 10和Chrome中可以正常工作。
$().ready(function() {
$("#I").val(3);
$("#I").focus(); // JQuery focus - does not work
var ctl = document.getElementById('I')
ctl.value='DOM';
ctl.focus(); // DOM Native focus - does not work
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type=text id=I>
$(document).ready(
呢? - Praveen Kumar Purushothaman