I am using
$(\'#list option\').each(function(){ //do stuff });
to loop over the options in a list. I am wondering how I could get the index of
jQuery takes care of this for you. The first argument to your .each() callback function is the index of the current iteration of the loop. The second being the current matched DOM element So:
.each()
$('#list option').each(function(index, element){ alert("Iteration: " + index) });