js query select all code example

Example 1: jquery get all select options

//looping through options select with jQuery
$("#mySelectID option").each(function(){
    var thisOptionValue=$(this).val();
});

Example 2: 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
}

Example 3: js select all

// This will select all of the text in the textarea or input called element
element.select();