Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 210

how can i get a value from a selected element (option), i have over 20 select element

$
0
0
  1. how can i select all the 'select element' from HTML, and get the value from the option selected.
  2. how can i retrieve value that's selected from the option,

i want to iterate through the select elements and get the selected value,like a dropdown list from an e-commence website, where a user can select the quantity of the product they want.

i tried using querySelectorAll to get all the 'select element'

document.querySelectorAll('.js-quantity-selector').forEach((selectedOption)=>{  const optionSelected = selectedOption.options[selectedOption.selectedIndex]; });

Viewing all articles
Browse latest Browse all 210

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>