迭代<select>选项
我在HTML中有一个<select>元素。 这个元素表示一个下拉列表。 我想了解如何通过JQuery来遍历<select>元素中的选项。 
 如何使用JQuery在<select>元素中显示每个选项的值和文本? 我只是想在alert()框中显示它们。 
 $("#selectId > option").each(function() { alert(this.text + ' ' + this.value); }); 
这对我有效
 $(function() { $("#select option").each(function(i){ alert($(this).text() + " : " + $(this).val()); }); }); 
也可以使用带索引和元素的参数化。
 $('#selectIntegrationConf').find('option').each(function(index,element){ console.log(index); console.log(element.value); console.log(element.text); }); 
//这也会起作用
 $('#selectIntegrationConf option').each(function(index,element){ console.log(index); console.log(element.value); console.log(element.text); }); 
而对于追随者来说,必须的,非jQuery的方式,因为谷歌似乎把每个人都发送到这里:
  var select = document.getElementById("select_id"); for (var i = 0; i < select.length; i++){ var option = select.options[i]; // now have option.text, option.value } 
也非jQuery
 Array.from(select).forEach(el => { // code });