Javascript DOM Document

Javascript examples for DOM:Document

Description

Click the following links for the tutorial for DOM and Document.

  1. Document removeEventListener() Method
  2. Document strictErrorChecking Property
  3. Document inputEncoding Property
  4. Document implementation Property
  5. Document documentURI Property
  6. Document documentElement Property
  7. Document doctype Property
  8. Document characterSet Property


  9. Document activeElement Property
  10. Document URL Property
  11. Document title Property - Change the title of the document:
  12. Document title Property
  13. Document referrer Property
  14. Document readyState Property
  15. Document lastModified Property - Convert the lastModified property into a Date object:
  16. Document lastModified Property


  17. Document head Property
  18. Document domain Property
  19. Document cookie Property
  20. Document body Property - Create a <p> element with some text and append it to the document's body:
  21. Document body Property - Change the HTML content of the current document and overwrite all existing HTML elements inside <body>
  22. Document body Property - Get the HTML content of the current document:
  23. Document body Property
  24. Document baseURI Property
  25. Document scripts Collection - Loop through all <script> elements in the document, and output the id of each script:
  26. Document scripts Collection namedItem(id) - Get the contents of the <script> element with id="myScript" in the document:
  27. Document scripts Collection item(index) - Get the contents of the first <script> element (index 0) in the document:
  28. Document scripts Collection [index] - Get the contents of the first <script> element (index 0) in the document:
  29. Document scripts Collection
  30. Document links Collection - Loop through all links in the document, and output the URL (href) of each link:
  31. Document links Collection - Add a red border to the first link in the document:
  32. Document links Collection namedItem(id) - Get the URL of the element with id="myLink" in the document:
  33. Document links Collection item(index) - Get the URL of the first link (index 0) in the document:
  34. Document links Collection [index] - Get the URL of the first link (index 0) in the document:
  35. Document links Collection
  36. Document images Collection - Loop through all <img> elements in the document, and output the URL (src) of each image:
  37. Document images Collection - Add a black dotted border to the first <img> element in the document:
  38. Document images Collection namedItem(id) - Get the URL of the <img> element with id="myImg" in the document:
  39. Document images Collection item(index) - Get the URL of the first <img> element (index 0) in the document:
  40. Document images Collection [index] - Get the URL of the first <img> element (index 0) in the document:
  41. Document images Collection
  42. Document forms Collection - Using the elements collection together with document.forms to get the value of each element in the form:
  43. Document forms Collection - Loop through all <form> elements in the document, and output the id of each form:
  44. Document forms Collection namedItem(id) - Get the HTML content of the <form> element with id="myCarForm" in the document:
  45. Document forms Collection item(index) - Get the id of the first <form> element (index 0) in the document:
  46. Document forms Collection [index] - Get the id of the first <form> element (index 0) in the document:
  47. Document forms Collection
  48. Document embeds Collection
  49. Document anchors Collection - Get the HTML content of the first <a> element in the document:
  50. Document anchors Collection
  51. Document getElementsByName() Method - Find out how many elements in the document with a name attribute = animal
  52. Document getElementsByName() Method
  53. Document close() Method - Using window.open() with document.open() to open an output stream in a new window, add some text, then close the output stream:
  54. Document close() Method
  55. Document createElement() Method
  56. Document createDocumentFragment() Method
  57. Document createComment() Method
  58. Document createAttribute() Method - Create a href attribute, with the value "www.book2s.com", and insert it to an <a> element:
  59. Document createAttribute() Method
  60. Document adoptNode() Method
  61. Document addEventListener() Method - For browsers that don't support the addEventListener() method, use the attachEvent() method.
  62. Document addEventListener() Method - Use removeEventListener() to remove an event handler attached by addEventListener() method:
  63. Document addEventListener() Method - Click to Change the background color of the document's <body> element:
  64. Document addEventListener() Method - Pass parameter values when using the addEventListener() method
  65. Document addEventListener() Method - Add different type of events to the document.
  66. Document addEventListener() Method - Add many events to the document without overwriting existing events, add two click events to the document
  67. Document addEventListener() Method - Assign "named" function to addEventListener() method
  68. Document addEventListener() Method
  69. Document writeln() Method
  70. Document write() Method - Write some text directly to the HTML document, with a new line using <br>
  71. Document write() Method - Difference between write() and writeln():
  72. Document write() Method - Open a new window called "MsgWindow", and write some text into it:
  73. Document write() Method - Open an output stream, add some text, then close the output stream:
  74. Document write() Method - use document.write() after an HTML document is fully loaded, will delete all existing HTML.
  75. Document write() Method - Write the Date object directly to the HTML document:
  76. Document write() Method - Write HTML elements with text directly to the HTML document:
  77. Document write() Method
  78. Document open() Method - Open an output stream with MIME type 'text/html', add some text, then close the output stream:
  79. Document open() Method
  80. Document getElementsByName() Method - Check all <input> elements with type="checkbox" with name attribute value "animal":
  81. Document querySelectorAll() Method - Set the background color of all <h2>, <div> and <span> elements in the document:
  82. Document querySelectorAll() Method - Set the background color of every <p> element where the parent is a <div> element:
  83. Document querySelectorAll() Method - Set the border of all <a> elements in the document that have a "target" attribute:
  84. Document querySelectorAll() Method - Set the background color of all <p> elements in the document:
  85. Document querySelectorAll() Method - Set the background color of all elements in the document with class="example":
  86. Document querySelectorAll() Method - Find out how many elements with class="example" there are in the document (using the length property of the NodeList object):
  87. Document querySelectorAll() Method - Get all <p> elements in the document with class="example", and set the background of the first <p> element:
  88. Document querySelectorAll() Method - Get all <p> elements in the document, and set the background color of the first <p> element (index 0):
  89. Document querySelectorAll() Method
  90. Document querySelector() Method - Use group selector in querySelector() method
  91. Document querySelector() Method - Get the first <a> element in the document that has a "target" attribute:
  92. Document querySelector() Method - Get the first <p> element in the document where the parent is a <div> element.
  93. Document querySelector() Method - Get the first <p> element in the document with class="example":
  94. Document querySelector() Method - Get the first <p> element in the document:
  95. Document querySelector() Method
  96. Document normalize() Method
  97. Document importNode() Method
  98. Document hasFocus() Method
  99. Document getElementsByTagName() Method - Using the "*" parameter.
  100. Document getElementsByTagName() Method - Change the background color of all <p> elements in the document:
  101. Document getElementsByTagName() Method - Change the HTML content of the first <p> element (index 0) in the document:
  102. Document getElementsByTagName() Method - Find out how many <li> elements there are in the document
  103. Document getElementsByTagName() Method
  104. Document getElementsByClassName() Method - Change the background color of all elements with class="example":
  105. Document getElementsByClassName() Method - Find out how many elements with class="example" there are in the document
  106. Document getElementsByClassName() Method
  107. Document getElementById() Method
  108. Document createTextNode() Method - Create a <p> element with some text:
  109. Document createTextNode() Method - Create a <h1> element with some text:
  110. Document createTextNode() Method
  111. Document createElement() Method - Create a <p> element with some text, and append it to the document:
  112. Document createElement() Method - Create a button with text: