disabled 属性は、ブール型属性です。
指定された場合、その要素は無効であることを指定します。
disabled 要素は、使用できません。
disabled 属性は、いくつかの他の条件が満たされるまで(チェックボックスを選択する等)、ユーザの要素使用から守るように設定することができます。 その後、JavaScript により無効になっ値を削除し、その要素を使用可能にできます。
disabled 属性は、以下の要素で使用することができます:
要素 | 属性 |
---|---|
<button> | disabled |
<fieldset> | disabled |
<input> | disabled |
<keygen> | disabled |
<optgroup> | disabled |
<option> | disabled |
<select> | disabled |
<textarea> | disabled |
関連するフォーム要素のグループを無効にします:
<fieldset disabled>
<legend>Personalia:</legend>
Name: <input type="text"><br>
Email: <input type="text"><br>
Date of birth: <input type="text">
</fieldset>
Try it Yourself ❯
無効な入力フィールドを持つ HTM Lフォーム:
<form
action="demo_form.html">
First name: <input type="text" name="fname"><br>
Last name:
<input type="text" name="lname"
disabled><br>
<input type="submit" value="Submit">
</form>
Try it Yourself ❯
無効な <keygen> 要素:
<form action="demo_keygen.html" method="get">
Username: <input type="text" name="usr_name">
Encryption: <keygen name="security" disabled>
<input type="submit">
</form>
Try it Yourself ❯
無効なオプション・グループ:
<select>
<optgroup label="German Cars" disabled>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
Try it Yourself ❯
1 つの無効な選択肢を持つドロップダウンリスト:
<select>
<option value="volvo" disabled>Volvo</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi">Audi</option>
</select>
Try it Yourself ❯
無効なドロップダウンリスト:
<select disabled>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
Try it Yourself ❯
無効なテキスト・エリア:
<textarea disabled>
At w3schools.com you will learn how to make a website. We offer free
tutorials in all web development technologies.
</textarea>
Try it Yourself ❯
disabled
属性は、要素ごとに以下のブラウザがサポートしています。
要素 | |||||
---|---|---|---|---|---|
button | Yes | Yes | Yes | Yes | Yes |
fieldset | Yes | サポートなし | Yes | 7.0 | Yes |
input | 1.0 | 6.0 | 1.0 | 1.0 | 1.0 |
keygen | Yes | サポートなし | Yes | 6.0 | Yes |
optgroup | 1.0 | 8.0 | Yes | Yes | Yes |
option | 1.0 | 8.0 | 1.0 | Yes | Yes |
select | Yes | Yes | Yes | Yes | Yes |
textarea | Yes | Yes | Yes | Yes | Yes |