Answers for "javascript get all options from select"

1

javascript get all select options

var options = document.getElementById('mySelectID').options;
for (let i = 0; i < options.length; i++) { 
  console.log(options[i].value);//log the value
}
Posted by: Guest on August-05-2019
2

javascript get all select options

//looping through options select with jQuery
$("#mySelectID option").each(function(){
    var thisOptionValue=$(this).val();
});
Posted by: Guest on August-05-2019
0

get all values of a select javascrip

//u have to put a unique id on your html select tag!
var options = document.getElementById('mySelectID'). options;
/*u can use this istead if u dont have an id in your select,
if u have only 1 select in your html*/
var options = document.querySelector('select').options;

//options.length gives the array dimension of var options
for (let i = 0; i < options. length; i++) {
//log the value.
console. log(options[i]. value);
}
Posted by: Guest on July-01-2021
0

js select all

// This will select all of the text in the textarea or input called element
element.select();
Posted by: Guest on December-04-2020
0

javascript get all options from select

x.options.length
Posted by: Guest on September-07-2020

Code answers related to "javascript get all options from select"

Code answers related to "Javascript"

Browse Popular Code Answers by Language