Iterate through <select> options
$("#selectId > option").each(function() {
alert(this.text + ' ' + this.value);
});
- http://api.jquery.com/each/
- http://jsfiddle.net/Rx3AP/
This worked for me
$(function() {
$("#select option").each(function(i){
alert($(this).text() + " : " + $(this).val());
});
});
can also Use parameterized each with index and the element.
$('#selectIntegrationConf').find('option').each(function(index,element){
console.log(index);
console.log(element.value);
console.log(element.text);
});
// this will also work
$('#selectIntegrationConf option').each(function(index,element){
console.log(index);
console.log(element.value);
console.log(element.text);
});