|
I know that there is an easy way to do this, but I'm so green on javascript programming that I'm missing something. Anyway, I have a div with some selects in it and I want to reset them all back to the first option. Here is my current code:
$("#newAuction").children('select').each(function () {
$(this).find('option:first').attr('selected', 'selected');
});
This isn't looping through all of the selects (there are four in this div) and resetting them to the first option. What am I doing wrong?
|
|
|
|
|
$('select option:first-child').attr("selected", "selected");
This will do all on a page. If you specifically want just the ones is a particular div then you can add that into the selector.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|