點評:想必大家一對HTML5的自動聚焦與占位文本有所了解了吧,要使用HTML5的自動聚焦功能,只需要在表單域中添加autofocus屬性即可,首先看下面要使用HTML自動聚焦和占位文本的示例代碼,感興趣的朋友 可以了解下哈
首先看下面要使用HTML自動聚焦和占位文本的示例代碼
復制代碼
代碼如下:
<!DOCTYPE html> 2: <html>
<head>
<title>注冊帳號</title>
<meta charset="utf-8">
</head>
<body>
<form method="post" action="goto">
<fieldset>
<legend>新用戶注冊</legend>
<ol>
<li>
<label for="name">郵 箱</label>
<input type="email">
</li>
<li>
<label for="user"> 用戶名</label>
<input type="text">
</li>
<li>
<label for="nickname"> 顯示名稱</label>
<input type="text">
</li>
<li>
<label for="password">密碼</label>
<input type="password">
</li>
<li>
<label for="confirm_password">確認密碼</label>
<input type="password">
</li>
</ol>
</fieldset>
</form>
</body>
</html>
復制代碼
代碼如下:
<li>
<label for="name">郵 箱</label>
<input type="email" autofocus>
</li>
復制代碼
代碼如下:
<ol>
<li>
<label for="name">郵 箱</label>
<input type="email" autofocus placeholder="請輸入有效的郵件地址">
</li>
<li>
<label for="user"> 用戶名</label>
<input type="text" placeholder="輸入用戶名">
</li>
<li>
<label for="nickname"> 顯示名稱</label>
<input type="text" placeholder="輸入昵稱">
</li>
<li>
<label for="password">密碼</label>
<input type="password" placeholder="輸入密碼">
</li>
<li>
<label for="confirm_password">確認密碼</label>
<input type="password" placeholder="再次輸入密碼">
</li>
</ol>
復制代碼
代碼如下:
<input type="password" autocomplete="off" placeholder="輸入密碼">
新聞熱點
疑難解答