input常用屬性

2022-06-02 23:45:20 字數 1668 閱讀 3571

對於input的使用,大家都很熟悉的,標籤用於蒐集使用者資訊。根據不同的 type 屬性值,輸入字段擁有很多種形式。輸入字段可以是文字字段、核取方塊、掩碼後的文字控制項、單選按鈕、按鈕等等。下面總結下個人經常使用過的一些屬性。  

text          文字域

button   按鈕

checkbox 複選

file    檔案型別限制

hidden  隱藏域

password   密碼域

radio   單選

reset   重置按鈕

submit  確認按鈕

type="text"

<

input

type

="text"

name

="名稱"

disabled

="disabled"

value

="禁用"

maxlength

="20"

size

="50"

>

<

input

type

="text"

name

="名稱"

readonly

="readonly"

value

="唯讀"

maxlength

="20"

size

="30"

>

效果圖

name —— 定義 input 元素的名稱。
disabled —— 當 input 元素載入時禁用此元素。
value —— 規定 input 元素的值。
maxlength —— 規定輸入欄位中的字元的最大長度。
size —— 定義輸入欄位的寬度。

比如之前做的上傳歌曲的demo,可以利用表單提交的方法。直接限制input type='file'的檔案型別限制,通過accept屬性進行設定,多個型別用逗號分隔開;multiple="multiple"是允許多個上傳;然後將它隱藏,ui層按鈕可以通過自定義乙個標籤來美化,可以寫這句**來觸發它

$("#picker").on("click",function

())

效果圖:

input 標籤常用屬性以及 type 的屬性值

input 標籤常用屬性 type 指定input型別 autocomplete 設定是否自動完成,其值為 on off autofocus 規定輸入欄位在頁面載入時是否獲得焦點,不適用於type hidden checked 預設選擇,對type值為 checkbox 及 radio 有效 dis...

input(標記屬性)

input 具有多種屬性,使用特定的屬性來完成頁面所需要的功能 例如 disabled禁用屬性,該屬性適用任何表單元素,其目的禁止元素的value值提交到伺服器中,使用disaled屬性後元素的背景則為灰色 input標籤屬性 屬性值 含義name name名 定義input元素的名稱 value ...

input標籤屬性

1.用input輸入文字 text型input元素可用的額外屬性 比較特殊的 dirname 指定元素內容文字方向的名稱 list 指定為文字框建議提供建議值的datalist元素 2.用input元素輸入密碼 pattern 指定乙個用於輸入驗證的正規表示式 required 表明使用者必須輸入乙...