JS Document object

Document Object Yes Yes a property of the window object, so you can document the object as a global object access.

When the browser loads an HTML document, it will be the  Document object .

Document object properties and methods

1.html element and the body object

  document.documentElement get root html element of the document

  document.body get body element of the document

2. Document Information

  document.title get the document title <title> My title </ title>

  document.URL returns the complete URL such as the document: {agreement}: // {username}: {@} password {hostname}:? {port number} / {path} / {file} {parameters}

  document.domain returns the current domain name of the document.

  document.referrer return load current page URL

3. Get element --Element

  getElementById();

  the getElementsByTagName (); tag

  getElementsByName();    name

  getElementsByClassName();

  querySelector (); Get the first matching element! () May be a standard form compliant css selector to css2. (Id, class, type, attribute, attribute value).

  querySelectorAll (); Get set of elements () may be a standard form compliant css selector to css2.

 4. Documentation written

  write () to write HTML expressions or JavaScript code to the document.

  open () opens a stream to collect from any write () or writeln output () method.

  close () Closes the input stream, and display the data

5. Special set

  1) document.anchors: Returns all elements with so <a> characteristics of the document.

  Returns all the same document <form> element, and document.getElementByTagName ( "form") to the results: 2) document.forms.

  3) document.images: Returns all <img> element, and document.getElementByTagName same document ( "img") to the result.

  4.document.links: <a> returns all elements with a href attribute of the document.

6. Other

  document.addEventListener () to document handler added

  removeEventListener() 

  document.cookie () to set or return all documents related to the current cookie

  createElement () to create an element node

  createTextNode () to create a text node

 

  

 

Guess you like

Origin www.cnblogs.com/zyueer/p/11327010.html