$(document).ready(function() { $("#txtUserPassword").keyup(function(e) { var curKey = e.which; if(curKey == 13) { document.getElementById("imgSenlan").focus(); } }) })
<div id="divUserPassword">
<input id="txtUserPassword" value="密码" name="txtUserPassword" type="text" maxlength=10 />
</div>
<div id="divDengru">
<img src="images/senlan.jpg" id="imgSenlan" /><p id="p_denglu">登 录</p>
</div>
这个是html
值能获得想txtUserName像这样的ID 而获得不到img图像的ID呢 连divTxt div的ID也获得不了?
话说
document.getElementById("imgSenlan")
换成$('#imgSenlan')
会不会好点,有时候我在jQ中用js的写法也会获取不到对象。