ड्रॉपडाउन लिस्ट के सभी विकल्प दिखाने के लिए, options प्रॉपर्टी उपयोग करें। यह प्रॉपर्टी आपको length प्रॉपर्टी के साथ सभी विकल्प प्राप्त करने की अनुमति देती है।
उदाहरण
ड्रॉप-डाउन लिस्ट से सभी विकल्प प्राप्त करने के लिए निम्न कोड चलाएं:
<!DOCTYPE html> <html> <body> <form id="myForm"> <select id="selectNow"> <option>One</option> <option>Two</option> <option>Three</option> </select> <input type="button" onclick="display()" value="Click"> </form> <p>Click the button to get all the options</p> <script> function display() { var a, i, options; a = document.getElementById("selectNow"); options = ""; for (i = 0; i < a.length; i++) { options = options + "<br> " + a.options[i].text; } document.write("DropDown Options: "+options); } </script> </body> </html>