select in javascript code example
Example 1: select element in js
var elem1 = document.getElementById("demo-id");
var elem2 = document.getElementsByClassName("demo-class");
var elem3 = document.getElementsByName("demo-name");
var elem4 = document.getElementsByTagName("p");
var elem1 = document.querySelector("#demo-id");
var elem2 = document.querySelectorAll(".demo-class");
var elem3 = document.querySelectorAll('[name="demo-name"]');
var elem4 = document.querySelectorAll("p");
Example 2: js select option in form
<form name="AddAndEdit">
<select name="list" id="personlist">
<option value="P1">Person1</option>
<option value="P2">Person2</option>
<option value="P3">Person3</option>
</select>
</form>
Example 3: select html js
var elem1 = document.getElementById("demo-id");
var elem2 = document.getElementsByClassName("demo-class");
var elem3 = document.getElementsByName("demo-name");
var elem4 = document.getElementsByTagName("p");
var elem1 = document.querySelector("#demo-id");
var elem2 = document.querySelectorAll(".demo-class");
var elem3 = document.querySelectorAll('[name="demo-name"]');
var elem4 = document.querySelectorAll("p");