I am trying to get values of specific option tags using jQuery.
This is my HTML:
<select name="modele" class="wyszselect" onchange="przenies(this[this.selectedIndex].value);"> <option value="0">Choose model</option> <option value="242">242</option> <option value="243">243</option> <option value="244">244</option> <option value="246">246</option> <option value="320">320</option> <option value="324">324</option> <option value="328">328</option> <option value="33">33</option> </select> This is my jQuery code:
$(document).ready(function () { var options = []; $("option").each(function (index, oneOption) { options.push(oneOption.attr("value")) }); console.log(options); }); I got this error:
Uncaught TypeError: oneOption.attr is not a function
oneOptionis a dom object,.attr()is a jquery function. You could useoneOption.value