当我手动构建我的输入时,我可以专注于它但是当我使用 JSF 标记生成我的输入时,表单名称会附加到 id 并且我不能再引用它。
我试过了
$("#username").focus();
和
$("#loginForm:username").focus();
没有任何运气。有什么建议吗?
这是生成的jsf html:
<input id="loginForm:username" type="text" name="loginForm:username" size="30" />
这就是我触发呼叫的方式...
$(document).ready(function() {
alert("checkA");
$("#username").focus();
alert("checkB");
});