Reset select to the default value


/ Published in: JavaScript
Save to your folder(s)

Sets the current element of a dropdown to the default option.

Afrikaans
English


Copy this code and paste it in your HTML
  1. resetDropdown : function() {
  2. var dropdown = this.getElementById('languageSelector');
  3. for (var i = dropdown.length-1; i >= 0; i--) {
  4. if (dropdown.options[i].defaultSelected) {
  5. dropdown.selectedIndex = i;
  6. break;
  7. }
  8. }
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.