html5自動獲取焦點


<html>
<head>
<title>自動獲得焦點</title>
<meta name="author" content="Yeeku.H.Lee(CrazyIt.org)" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
姓名:<input type="textarea" name="xinming"/><br/>
年齡:<input type="textarea" autofocus name="age"/>
</html>
<!-- HTML5自動獲取焦點, autofocus-->

<!-- HTML獲取焦點,比較 -->

<html>
<head>
<title>不是自動獲取焦點</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
姓名:<input type="text" name="xinming" id="xinming"/><br/>
年齡:<input type="text" name="age" id="age"/>
</body>
</html>
<script type="text/javascript">
document.getElementById("xinming").focus();
</script>

<!-- 普通用js獲取-->

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM