HTML DOM Seçenek Nesnesi
Seçenek Nesnesi
Option nesnesi bir HTML <option> öğesini temsil eder.
Bir Seçenek Nesnesine Erişin
Bir <option> öğesine getElementById() kullanarak erişebilirsiniz:
Örnek
var x = document.getElementById("myOption");
İpucu: Bir formun öğe koleksiyonunda veya bir açılır listenin seçenekler koleksiyonunda arama yaparak bir Option nesnesine de erişebilirsiniz .
Bir Seçenek Nesnesi Oluşturun
Document.createElement() yöntemini kullanarak bir <option> öğesi oluşturabilirsiniz:
Örnek
var x = document.createElement("OPTION");
Seçenek Nesne Özellikleri
Property | Description |
---|---|
defaultSelected | Returns the default value of the selected attribute |
disabled | Sets or returns whether an option is disabled, or not |
form | Returns a reference to the form that contains the option |
index | Sets or returns the index position of an option in a drop-down list |
label | Sets or returns the value of the label attribute of an option in a drop-down list |
selected | Sets or returns the selected state of an option |
text | Sets or returns the text of an option |
value | Sets or returns the value of an option to be sent to the server |
Standart Özellikler ve Etkinlikler
Option nesnesi ayrıca standart özellikleri ve olayları da destekler .
İlgili Sayfalar
HTML referansı: HTML <option> etiketi