Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
194
rated 0 times [  195] [ 1]  / answers: 1 / hits: 9323  / 10 Years ago, wed, march 26, 2014, 12:00:00

I need to run a function for each item in a drop down menu. The code is:



    $( document ).ready(function() {
$('[id*=lwayer_x002d_EisDikigoros_1eef9a23-7a35-4dcf-8de9-a088b4681b2b]')
.each(function(index) {
/* here, I need to do some manipulation on the item */
console.log(index is:+???+value is+???);
});

});


I understand that i need to put something before each() to select all items but I don't know what to put



Thank you



The drop down menu is :
<select id=lwayer_x002d_EisDikigoros_1eef9a23-7a35-4dcf-8de9-a088b4681b2b_$LookupField title=Εισ. Δικηγόρος/οι>
<option value=0>(None)</option> <option value=1>(Name1)</option> etc

More From » jquery

 Answers
24

Try this:



$(document).ready(function(){
$('select[id*=lwayer_x002d_EisDikigoros_1eef9a23-7a35-4dcf-8de9-a088b4681b2b] option').each(function(index,value) {
console.log(index is:+index); // index
console.log(value is+$(this).val()); // dropdown option value
console.log(dropdown text value is+$(this).text()); //dropdown option text
});
});


DEMO


[#46528] Tuesday, March 25, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
soniap

Total Points: 626
Total Questions: 119
Total Answers: 110

Location: Palestine
Member since Tue, Jul 20, 2021
3 Years ago
;