एचटीएमएल डोम विकल्प वस्तु
विकल्प वस्तु
विकल्प ऑब्जेक्ट एक HTML <विकल्प> तत्व का प्रतिनिधित्व करता है।
एक विकल्प वस्तु तक पहुँचें
आप getElementById() का उपयोग करके <विकल्प> तत्व तक पहुंच सकते हैं:
उदाहरण
var x = document.getElementById("myOption");
युक्ति: आप किसी प्रपत्र के तत्वों के संग्रह, या ड्रॉप-डाउन सूची के विकल्प संग्रह के माध्यम से खोज कर भी एक विकल्प ऑब्जेक्ट तक पहुंच सकते हैं ।
एक विकल्प वस्तु बनाएँ
आप document.createElement() विधि का उपयोग करके एक <विकल्प> तत्व बना सकते हैं:
उदाहरण
var x = document.createElement("OPTION");
विकल्प वस्तु गुण
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 |
मानक गुण और घटनाएँ
विकल्प ऑब्जेक्ट मानक गुणों और घटनाओं का भी समर्थन करता है ।
संबंधित पृष्ठ
HTML संदर्भ: HTML <विकल्प> टैग