dynamic-boguskids.html 883 B

1234567891011121314151617181920212223242526272829303132
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. function doIt() {
  6. var insertions = [
  7. [ "opt1", "Shouldn't see me" ],
  8. [ "opt2", "Or me" ],
  9. [ "opt3", "I should hide too" ],
  10. [ "opt4", "And me too" ]
  11. ];
  12. for (var i = 0; i < insertions.length; ++i) {
  13. var next = document.getElementById(insertions[i][0]);
  14. next.parentNode.insertBefore(document.createTextNode(insertions[i][1]),
  15. next);
  16. }
  17. document.getElementById("sel").appendChild(document.createTextNode("And I"));
  18. }
  19. </script>
  20. </head>
  21. <body onload="doIt()">
  22. <select size="10" id="sel">
  23. <option id="opt1">one</option>
  24. <option id="opt2">two</option>
  25. <optgroup>
  26. <option id="opt3">three</option>
  27. <option id="opt4">four</option>
  28. </optgroup>
  29. </select>
  30. </body>
  31. </html>