DOM operations in javascript (2)

Source: Internet
Author: User

<Html> <title> learn DOM </title> <a id = "wen"> text </a> <input name = "myinput" type = "text"> <input name = "myinput" type = "text"> <input name = "myinput" type = "text"> <input name = "myinput" type = "text"> <script> /* // attributes of the document in the 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 of the current document. write (document. URL); // http: // localhost/js/dom/04.html // The document method in the window // getElementById () 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 = "

 

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.