重置表單
<input>的[type]屬性值爲"button"的時候表示一個普通的按鈕,相當於一個<button>標籤。
<input>的[type]屬性值爲"reset"時,表示表單重置,它在頁面的表現形式也是個按鈕,但點擊他的時候會讓表單重置到頁面剛加載時的狀態。
看一段代碼吧:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="index.css"> <title>表單</title> </head> <body> <form action="/" method="get"> <h2>input標籤 -- 重置表單</h2> <p><label for="account">賬號:</label><input type="text" id="account"/></p> <p><label for="psd">密碼:</label><input type="password" id="psd"/></p> <input type="reset" value="重置"> </form> </body> </html>
更多學習內容,就在碼芽網http://www.mayacoder.com/lesson/index
結果是這樣的:
重置後: