Answers for "how to select option from select javascript"

3

select element in js

//<div id="demo-id"></div>
var elem1 = document.getElementById("demo-id");
//<div class="demo-class"></div>
var elem2 = document.getElementsByClassName("demo-class");
//<div name="demo-name"></div>
var elem3 = document.getElementsByName("demo-name");
//<p>Some text</p>
var elem4 = document.getElementsByTagName("p");

//<div id="demo-id"></div>
var elem1 = document.querySelector("#demo-id");
//<div class="demo-class"></div>
var elem2 = document.querySelectorAll(".demo-class");
//<div name="demo-name"></div>
var elem3 = document.querySelectorAll('[name="demo-name"]');
//<p>Some text</p>
var elem4 = document.querySelectorAll("p");
Posted by: Guest on May-17-2021
0

javascript select element in dropdown

document.getElementById("stateSelect").selected = true;
Posted by: Guest on April-24-2020

Code answers related to "how to select option from select javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language