A tentative study of JavaScript two

Source: Internet
Author: User
Tags tag name

----------Summary
01. Finding DOM Elements
document.getElementById ();//Get a DOM element by ID
Document.getelementsbyclassname ();//Get DOM array by class
document.getElementsByTagName ();//get DOM array by tag name


02. Modifying DOM elements
Dom.type = "Text"//type property
dom.innerhtml//double Label text value here note innertext
dom.value//Modify the text value of a single label, such as input
document.getElementById (). style.height//Note styles need to be added by style points, height, width need to add units


03. Delete DOM Elements
DOM element. Parentnode.removechild (DOM Element)//dom elements cannot delete themselves, they must be deleted by the parent element
The deleted DOM element is still in memory, just removing it from the DOM tree.


04. Creating DOM Elements
Document.createelement ("input");//In JS All DOM elements are created in this way, passing in different tag names, returning different elements
DOM element. AppendChild (NewNode)//Create good DOM elements you have to add him to the DOM tree to see it.


05. Cloning DOM Elements
DOM element. CloneNode (TRUE);//All DOM elements have this method, passing in false only clones the element itself, passing in true child elements together to clone


06.a Tag introduces JS code
<a href= "javascript: Write JS code here" > Test with </a>//in javascript: after writing JS code


Special for 07.select labels
01. You can modify the selected option by setting the Select.value. However, the value set must have the option tag present, otherwise no effect
02. Modify the selected option tag to trigger the onchange event for the Select tag


08. Second way to bind level 0 DOM events
<input type= ' button ' onclick= ' is written here is the JS code ' >//Note this binding method body inside this


09. Get the parent node quickly

DOM element. parentnode


10. Note
When writing JS may not prompt, bold write up to!!!!!

<! DOCTYPE html>

  

<! DOCTYPE html>

  

<! DOCTYPE html>

  

<! DOCTYPE html>

<! DOCTYPE html>

  

<! DOCTYPE html>

  

<! DOCTYPE html>

  

<! DOCTYPE html>

  

A tentative study of JavaScript two

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.