js中怎么使点击按钮后文本框获得焦点

<html>
<head>
<script type="text/javascript">
function setFocus()
  {
  document.getElementById('password1').focus()
  }
function loseFocus()
  {
  document.getElementById('password1').blur()
  }
</script>
</head>
<body>
 
<form>
<input type="password" id="password1" value="thgrt456" />
<input type="button" onclick="setFocus()" value="Set focus" />
<input type="button" onclick="loseFocus()" value="Lose focus" />
</form>
 
</body>
</html>

  

posted @ 2019-04-24 10:04  码农编程进阶笔记  阅读(1912)  评论(0编辑  收藏  举报
返回顶部 有事您Q我