Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.34 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. reset a select element
  2. selectElement.options[0].selected=true;
  3.        
  4. Uncaught TypeError: Cannot read property '0' of undefined
  5.        
  6. <select id="selectElement">
  7.     <option>First</option>
  8.     <option selected>Second</option>
  9. </select>
  10.        
  11. selectElement.options[0].selected="selected";
  12.        
  13. document.getElementById('mySelect').selectedIndex = 0;