Check if option is selected, if not select default


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

Very useful for changing the selected option in a select dropdown


Copy this code and paste it in your HTML
  1. var foo = document.getElementById('yourSelect');
  2. if (foo)
  3. {
  4. if (foo.selectedIndex != null)
  5. {
  6. foo.selectedIndex = 0;
  7. }
  8. }

URL: www.CordSlatton.com

Report this snippet


Comments


You need to login to view comments.