& Lt; html & gt; & lt; title & gt; learn DOM & lt;/title & gt; & lt; aid & quot; wen & quot; & gt; text & lt;/a & gt; & lt; inputname & quot; myinput & quot; type & quot; text & quot; & gt; & lt; inputname & quot; myi
Learn DOMTextThe attributes of the document in script/* // window // you can set or query all cookies related to the current document. Document. write (document. cookie); // The domain attribute returns the server domain name for downloading the current document. Document. write (document. domain); // localhost // The lastModified attribute returns the Last modified Date and time of the document. Document. write (document. lastModified); // The title attribute returns the title of the current document (text in the HTML title element ). Document. write (document. title); // learn DOM // The URL attribute to return the URL document. write (document. URL) of the current document );// http://localhost/js/dom/04.html // The document method in the window // The getElementById () method returns a reference to the first object with the specified ID. Var x = document. getElementById ('wen'); alert (x. innerHTML); // text // The getElementsByName () method returns a set of objects with the specified name. var x = document. getElementsByName ("myinput"); alert (x. length); // 4 // The getElementsByTagName () method returns a set of objects with the specified tag name var x = document. getElementsByTagName ('input'); alert (x. length); // 4 // The open () method can open a new document and erase the content of the current document. // The close () method can close an output stream opened by the document. open Method and display the selected data. Var newDoc = document. open ("text/html", "replace"); var txt ="Learning about the DOM is FUN!"; NewDoc. write (txt); newDoc. close (); // The write () method can write HTML expressions or JavaScript code to the document. Multiple parameters (exp1, exp2, exp3,...) can be listed, and they will be appended to the document in order. Document. write ('giggle ', 'haha'); // the method of the writeln () method works the same as that of the write () method, and a line break can be written after each expression. Document. writeln ('giggle ', 'haha'); // giggle Haha */script