JS Learning Road Series Summary of the four image array (this article is like martial arts in the Easy Rib, is you gallop it field of martial arts heart, learn JS five big Zhenfa learned JS, Bo Master proposed to learn three before the first array)

Source: Internet
Author: User


Four elephant zhenfa: Add delete Change find "in order to facilitate memory, reduce the use of brain memory, I named JS Heart for: Tao Zhenfa, two instruments ZHENFA, three just ZHENFA, four like Zhenfa, five lines zhenfa, just remember ZHENFA keyword, you can search the brain of the corresponding content, learn JS five Zhenfa can learn JS"

Dom operation additions and deletions (Document Object model)

Add nodes:

var div=document.createelement ("div");

var text=document.createtextnode ("I am a text node");

Fathernode.appchild (Childnode); "Add Childnode inside Fathernode element"

Fathernode.insertbefore (Insertnode,targetnode); "Add Childnode inside Fathernode element"

Node.clonenode (ture); "True to replicate node nodes and their child nodes, false to copy only node nodes, false when not filled, false when an IMG tag is copied"

To delete a node:

Fathernode.removechild (Childnode); "Delete Fathernode element internal node Childnode"

To change the node:

Fathernode.replacechild (Replacenode,targetnode); "If ReplaceNode is an existing node, the target will be deleted and the ReplaceNode placed here"


Find:

var Idselector=document.getelementbyid ("#selector");

var tagselector=document.getelementsbytagname ("div");

var tagselector=idselector.getelementsbytagname ("div"); "Select only Idselector div"

H5 element Selector

var classselector=document.getelementsbyclassname (". Selector") "Support ie9+"

var query=document.queryselector ("#selector") "support all selectors in CS" "Support ie8+" "returns the first matching element"

var queryall=document.queryselectorall (". Selector") "support all selectors in CS" "Support ie8+" "Returns all matching node list NodeList class array"

"Classlist Series ie9+ Support"

Classlist.add ("Class1,class2 ...") "Add one or more class names"

Classlist.remove ("Class1,class2 ...") "Delete one or more class names"

Classlist.toggel ("class") "Toggle class name"

Classlist.contains ("class") "Determines whether the class name exists, exists not true, does not exist as false"

Claslist.item (Index) "Returns the class name for the specified index"

Classlist.length "Returns the number of class names"

JS Learning Road Series Summary of the four image array (this article is like martial arts in the Easy Rib, is you gallop it field of martial arts heart, learn JS five big Zhenfa learned JS, Bo Master proposed to learn three before the first array)

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.