js鼠标光标定位到原来的input

为什么在一个input里用鼠标定位到别的input可以定位到本身不行呢?怎么解决代码如下<html><head><metahttp-equiv="Content-Type... 为什么在一个input里用鼠标定位到别的input可以 定位到本身不行呢?怎么解决
代码如下
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<script lang="javascript">
function check()
{
alert("asdfasdf");
document.getElementById("name").focus();
}
</script>

<body>
<p><b>This is for Molly.</b></p>
<table width="80%">
<input type="text" value="Molly" id="name" size="12" onchange="check()"> <br> </tr>
<input type="password" size="12" id="pin" > <br>
<tr> "onkeydown=if(event.keyCode==13){event.keyCode=9}" in source code is for 'Enter' key function change" </tr>
</table>
</body>
</html>
展开
 我来答
lzd_camel
2016-03-10
知道答主
回答量:4
采纳率:0%
帮助的人:4573
展开全部
setTimeout(function(){
document.getElementById("name").focus();
}, 0);

这样就可以了,我试了成功了,focus()在IE下哟bug
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
njurst
2014-06-13 · 超过72用户采纳过TA的回答
知道小有建树答主
回答量:195
采纳率:0%
帮助的人:137万
展开全部
document.getElementById("name").focus().select();
这样就行了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式