<input> type 屬性
1
語法 :<input type="value">
實例:
1.button:定義可點擊的按鈕;定義可點擊的按鈕,在用戶單擊按鈕時啟動一段 JavaScript:
<input type="button" value="點我" onclick="msg()">
2.checkbox:定義復選框;復選框允許用戶在一定數量的選擇中選取一個或多個選項:
<input type="checkbox" name="vehicle[]" value="Bike"> 吃<br>
<input type="checkbox" name="vehicle[]" value="Car"> 睡<br>
<input type="checkbox" name="vehicle[]" value="Boat"> 玩<br>
3.color:定義拾色器。
選擇你喜歡的顏色: <input type="color" name="favcolor"><br>
18 4.date:定義 date 控件(包括年、月、日,不包括時間)。
生日: <input type="date" name="bday">
5.datetime:定義 date 和 time 控件(帶有時區):
生日(日期和時間):<input type="datetime" name="bdaytime">
6.datetime-local:定義 date 和 time 控件(不帶時區):
生日 (日期和時間):<input type="datetime-local" name="bdaytime"> 7.email:定義用於e-mail地址的字段 E-mail: <input type="email" name="usremail">8.file:定義文件選擇字段和“瀏覽”按鈕,供文件上傳:
選擇一個文件: <input type="file" name="img">
9.hidden:定義隱藏字段,隱藏字段對於用戶是不可見的。隱藏字段常常存儲默認值,或者由 JavaScript 改變它們的值:
<input type="hidden" name="country" value="Norway">
10. image:定義圖像作為提交按鈕:
<input type="image" src="img_submit.gif" alt="Submit">
11.month:定義 month 和 year 控件(不帶時區)。
生日 ( 月和年 ): <input type="month" name="bdaymonth">
12.number:定義用於輸入數字的字段(您可以設置可接受數字的限制):
數量 ( 1 到 5 之間): <input type="number" name="quantity" min="1" max="5">
13.password:定義密碼字段(密碼字段中的字符會被遮蔽):
<input type="password" name="pwd">
14.radio:允許用戶在一定數量的選擇中選取一個選項:
<input type="radio" name="gender" value="male"> Male<br><input type="radio" name="gender" value="女"> 女
15.range:定義用於精確值不重要的輸入數字的控件(比如 slider 控件)。您也可以設置可接受數字的限制:
<input type="range" name="points" min="1" max="10"> 16.reset:定義重置按鈕(重置所有表單值為默認值): <input type="reset">
17.search:定義搜索字段(比如站內搜索或谷歌搜索等):
Search Google: <input type="search" name="googlesearch">18.submit:定義提交按鈕:
<input type="submit">19.tel:定義用於輸入電話號碼的字段:
電話號碼: <input type="tel" name="usrtel">20.text:定義兩個用戶可向其中輸入文本的單行的文本字段:
First name: <input type="text" name="fname"><br>Last name: <input type="text" name="lname"><br>
21.url:定義用於輸入 URL 的字段:
添加你的主頁: <input type="url" name="homepage">22.week:定義 week 和 year 控件(不帶時區):
選擇周: <input type="week" name="week_year">
<input> type 屬性