2017年9月1日 星期五

label for以及focus method都可以做到的事件


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<label for="username">方法一:按我直接去focus那個input</label>
<br><br><br>
<input type="text" id="username">
<br><br><br>
<p id="p">方法二:按我直接去focus那個input</p>
<br><br><br>
<input type="password" id="password">

<script type="text/javascript">
document.getElementById('p').onclick=function(){
document.getElementById('password').focus();
}
</script>

</body>
</html>




沒有留言:

張貼留言