DOM operations in javascript (2)

Source: Internet
Author: User
& 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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.