SlideShare a Scribd company logo
The most common DOM methods at a glance
Reaching Elements in a Document                                                      Creating New Nodes
document.getElementById('id'): Retrieves the element with                             document.createElement(element): Creates a new element
the given id as an object                                                             node with the name element. You provide the name as a string.
document.getElementsByTagName('tagname'): Retrieves all                               document.createTextNode(string): Creates a new text node
elements with the tag name tagname and stores them in an array-                       with the node value of string.
like list
                                                                                      newNode = node.cloneNode(bool): Creates newNode as a copy
Reading Element Attributes, Node Values and Other Data                                (clone) of node. If bool is true, the clone includes clones of all the
                                                                                      child nodes of the original.
node.getAttribute('attribute'): Retrieves the value of the
                                                                                      node.appendChild(newNode): Adds newNode as a new (last) child
attribute with the name attribute
                                                                                      node to node.
node.setAttribute('attribute', 'value'): Sets the value
                                                                                      node.insertBefore(newNode,oldNode): Inserts newNode as a
of the attribute with the name attribute to value
                                                                                      new child node of node before oldNode.
node.nodeType: Reads the type of the node (1 = element, 3 = text
                                                                                      node.removeChild(oldNode): Removes the child oldNode from
node)
                                                                                      node.
node.nodeName: Reads the name of the node (either element
                                                                                      node.replaceChild(newNode, oldNode): Replaces the child
name or #textNode)
                                                                                      node oldNode of node with newNode.
node.nodeValue: Reads or sets the value of the node (the text
                                                                                      element.innerHTML: Reads or writes the HTML content of the given
content in the case of text nodes)
                                                                                      element as a string—including all child nodes with their attributes and
Navigating Between Nodes                                                              text content.

node.previousSibling: Retrieves the previous sibling node and                        Known browser quirks:
stores it as an object.
                                                                                      getAttribute and setAttribute are not reliable. Instead, assign
node.nextSibling: Retrieves the next sibling node and stores it                       the property of the element object directly: obj.property = value.
as an object.                                                                         Furthermore, some attributes are actually reserved words, so instead
node.childNodes: Retrieves all child nodes of the object and                          of class use className and instead of for use HTMLfor.
stores them in an list. here are shortcuts for the first and last child               Real DOM compliant browsers will return linebreaks as text nodes in
node, named node.firstChild and node.lastChild.                                       the childNodes collection, make sure to either remove them or test
node.parentNode: Retrieves the node containing node.                                  for the nodeType.




                           Assembled by Christian Heilmann (http://wait-till-i.com), licensed Creative Commons Attribution (http://creativecommons.org/licenses/by/3.0/). Enjoy.

More Related Content

What's hot (14)

Binary tree in java
Binary tree in javaBinary tree in java
Binary tree in java
Programming Homework Help
 
Data perisistence in iOS
Data perisistence in iOSData perisistence in iOS
Data perisistence in iOS
mobiledeveloperpl
 
GPU programming
GPU programmingGPU programming
GPU programming
Roberto Bonvallet
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)
Abu Saleh
 
What is String in Java?
What is String in Java?What is String in Java?
What is String in Java?
RAKESH P
 
Cordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced JavascriptCordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced Javascript
Binu Paul
 
Unit7 jwfiles
Unit7 jwfilesUnit7 jwfiles
Unit7 jwfiles
mrecedu
 
Brief Summary Of C++
Brief Summary Of C++Brief Summary Of C++
Brief Summary Of C++
Haris Lye
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
Stefano Fago
 
โค้ด
โค้ดโค้ด
โค้ด
MareenaHahngeh
 
front-end dev
front-end devfront-end dev
front-end dev
Paul Comanici
 
Excel to Use Rest API to communicate with a server
Excel to Use Rest API to communicate with a serverExcel to Use Rest API to communicate with a server
Excel to Use Rest API to communicate with a server
docuboy
 
Krazykoder struts2 internationalization
Krazykoder struts2 internationalizationKrazykoder struts2 internationalization
Krazykoder struts2 internationalization
Krazy Koder
 
Data Types/Structures in DivConq
Data Types/Structures in DivConqData Types/Structures in DivConq
Data Types/Structures in DivConq
eTimeline, LLC
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)
Abu Saleh
 
What is String in Java?
What is String in Java?What is String in Java?
What is String in Java?
RAKESH P
 
Cordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced JavascriptCordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced Javascript
Binu Paul
 
Unit7 jwfiles
Unit7 jwfilesUnit7 jwfiles
Unit7 jwfiles
mrecedu
 
Brief Summary Of C++
Brief Summary Of C++Brief Summary Of C++
Brief Summary Of C++
Haris Lye
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
Stefano Fago
 
Excel to Use Rest API to communicate with a server
Excel to Use Rest API to communicate with a serverExcel to Use Rest API to communicate with a server
Excel to Use Rest API to communicate with a server
docuboy
 
Krazykoder struts2 internationalization
Krazykoder struts2 internationalizationKrazykoder struts2 internationalization
Krazykoder struts2 internationalization
Krazy Koder
 
Data Types/Structures in DivConq
Data Types/Structures in DivConqData Types/Structures in DivConq
Data Types/Structures in DivConq
eTimeline, LLC
 

Viewers also liked (12)

Programa academico(profesiones)
Programa academico(profesiones)Programa academico(profesiones)
Programa academico(profesiones)
laurafernandacastillo
 
Bancos De Cordon Umbilical
Bancos De Cordon Umbilical
Bancos De Cordon Umbilical
Bancos De Cordon Umbilical
seccionmadre
 
The Individual Credibility Process of Internet Users
The Individual Credibility Process of Internet UsersThe Individual Credibility Process of Internet Users
The Individual Credibility Process of Internet Users
Elizabeth Beasley
 
Video analysis
Video analysisVideo analysis
Video analysis
Sam_C_Ryder
 
Dna structure
Dna structureDna structure
Dna structure
vjcummins
 
Base de datos ii
Base de datos iiBase de datos ii
Base de datos ii
Susi Perez Gallegos
 
APP 概念工作坊
APP 概念工作坊APP 概念工作坊
APP 概念工作坊
Tim Hong
 
CALENDARIO DE RECUPERACIONES
CALENDARIO DE RECUPERACIONESCALENDARIO DE RECUPERACIONES
CALENDARIO DE RECUPERACIONES
moniki
 
Onet computer
Onet computer Onet computer
Onet computer
Ffurn Leawtakoon
 
Twitter as a Universal Information Stream
Twitter as a Universal Information StreamTwitter as a Universal Information Stream
Twitter as a Universal Information Stream
rdale
 
ゲームのレビューから収集した意見の集約
ゲームのレビューから収集した意見の集約ゲームのレビューから収集した意見の集約
ゲームのレビューから収集した意見の集約
utsuro_lab
 
How to solve Ramanujan's problem by numerical method 1
How to solve Ramanujan's problem by numerical method 1How to solve Ramanujan's problem by numerical method 1
How to solve Ramanujan's problem by numerical method 1
สมต๋อง มข.
 
Bancos De Cordon Umbilical
Bancos De Cordon Umbilical
Bancos De Cordon Umbilical
Bancos De Cordon Umbilical
seccionmadre
 
The Individual Credibility Process of Internet Users
The Individual Credibility Process of Internet UsersThe Individual Credibility Process of Internet Users
The Individual Credibility Process of Internet Users
Elizabeth Beasley
 
Dna structure
Dna structureDna structure
Dna structure
vjcummins
 
APP 概念工作坊
APP 概念工作坊APP 概念工作坊
APP 概念工作坊
Tim Hong
 
CALENDARIO DE RECUPERACIONES
CALENDARIO DE RECUPERACIONESCALENDARIO DE RECUPERACIONES
CALENDARIO DE RECUPERACIONES
moniki
 
Twitter as a Universal Information Stream
Twitter as a Universal Information StreamTwitter as a Universal Information Stream
Twitter as a Universal Information Stream
rdale
 
ゲームのレビューから収集した意見の集約
ゲームのレビューから収集した意見の集約ゲームのレビューから収集した意見の集約
ゲームのレビューから収集した意見の集約
utsuro_lab
 
How to solve Ramanujan's problem by numerical method 1
How to solve Ramanujan's problem by numerical method 1How to solve Ramanujan's problem by numerical method 1
How to solve Ramanujan's problem by numerical method 1
สมต๋อง มข.
 
Ad

Similar to Java script dom-cheatsheet) (20)

DOM and Events
DOM and EventsDOM and Events
DOM and Events
Julie Iskander
 
12. session 12 java script objects
12. session 12   java script objects12. session 12   java script objects
12. session 12 java script objects
Phúc Đỗ
 
iOS Session-2
iOS Session-2iOS Session-2
iOS Session-2
Hussain Behestee
 
INTRODUCTION TO DOM AND DOM TREE
INTRODUCTION TO DOM AND DOM TREEINTRODUCTION TO DOM AND DOM TREE
INTRODUCTION TO DOM AND DOM TREE
systematiclab
 
Javascript closures
Javascript closures Javascript closures
Javascript closures
VNG
 
Dom
Dom Dom
Dom
Surinder Kaur
 
6867389.ppt
6867389.ppt6867389.ppt
6867389.ppt
SunilChaluvaiah
 
6867389 (1).ppt
6867389 (1).ppt6867389 (1).ppt
6867389 (1).ppt
SunilChaluvaiah
 
6867389.ppt
6867389.ppt6867389.ppt
6867389.ppt
SunilChaluvaiah
 
Drupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.comDrupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.com
JD Leonard
 
java classes
java classesjava classes
java classes
Vasu Devan
 
descriptive programming
descriptive programmingdescriptive programming
descriptive programming
Anand Dhana
 
JNDI
JNDIJNDI
JNDI
Shobana Pattabiraman
 
Chapter4.pptxdgdhgfshsfhtgjsjryjusryjryjursyj
Chapter4.pptxdgdhgfshsfhtgjsjryjusryjryjursyjChapter4.pptxdgdhgfshsfhtgjsjryjusryjryjursyj
Chapter4.pptxdgdhgfshsfhtgjsjryjusryjryjursyj
berihun18
 
dom.ppt
dom.pptdom.ppt
dom.ppt
MuhammadAdnan845624
 
About Python
About PythonAbout Python
About Python
Shao-Chuan Wang
 
11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objects
Phúc Đỗ
 
Html dom part-ii
Html dom part-iiHtml dom part-ii
Html dom part-ii
H K
 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh maloth
Bhavsingh Maloth
 
Ado.net session13
Ado.net session13Ado.net session13
Ado.net session13
Niit Care
 
12. session 12 java script objects
12. session 12   java script objects12. session 12   java script objects
12. session 12 java script objects
Phúc Đỗ
 
INTRODUCTION TO DOM AND DOM TREE
INTRODUCTION TO DOM AND DOM TREEINTRODUCTION TO DOM AND DOM TREE
INTRODUCTION TO DOM AND DOM TREE
systematiclab
 
Javascript closures
Javascript closures Javascript closures
Javascript closures
VNG
 
Drupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.comDrupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.com
JD Leonard
 
descriptive programming
descriptive programmingdescriptive programming
descriptive programming
Anand Dhana
 
Chapter4.pptxdgdhgfshsfhtgjsjryjusryjryjursyj
Chapter4.pptxdgdhgfshsfhtgjsjryjusryjryjursyjChapter4.pptxdgdhgfshsfhtgjsjryjusryjryjursyj
Chapter4.pptxdgdhgfshsfhtgjsjryjusryjryjursyj
berihun18
 
11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objects
Phúc Đỗ
 
Html dom part-ii
Html dom part-iiHtml dom part-ii
Html dom part-ii
H K
 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh maloth
Bhavsingh Maloth
 
Ado.net session13
Ado.net session13Ado.net session13
Ado.net session13
Niit Care
 
Ad

Recently uploaded (20)

Cora Bisignano PPH Presentation (1).pdf
Cora Bisignano PPH Presentation  (1).pdfCora Bisignano PPH Presentation  (1).pdf
Cora Bisignano PPH Presentation (1).pdf
corabisi
 
SUN PATH AND SHADOW ANGLESarchitrcture.pdf
SUN PATH AND SHADOW ANGLESarchitrcture.pdfSUN PATH AND SHADOW ANGLESarchitrcture.pdf
SUN PATH AND SHADOW ANGLESarchitrcture.pdf
14ANUSHAVPARCHI
 
Villa de'Urgell X -.pdf A single family two-story residence to be built in tw...
Villa de'Urgell X -.pdf A single family two-story residence to be built in tw...Villa de'Urgell X -.pdf A single family two-story residence to be built in tw...
Villa de'Urgell X -.pdf A single family two-story residence to be built in tw...
Manny Vesa
 
Midwifery_Led_Care_Units_Presentation.pptx
Midwifery_Led_Care_Units_Presentation.pptxMidwifery_Led_Care_Units_Presentation.pptx
Midwifery_Led_Care_Units_Presentation.pptx
rajanirprasadkrishna
 
ARTS IN DAILY LIVING-DRAWING TECHNIQUES_125650.pptx
ARTS IN DAILY LIVING-DRAWING TECHNIQUES_125650.pptxARTS IN DAILY LIVING-DRAWING TECHNIQUES_125650.pptx
ARTS IN DAILY LIVING-DRAWING TECHNIQUES_125650.pptx
christopherdada99
 
Styled_Soyabean_Milk_Presentation (1).pptx
Styled_Soyabean_Milk_Presentation (1).pptxStyled_Soyabean_Milk_Presentation (1).pptx
Styled_Soyabean_Milk_Presentation (1).pptx
ssuser1abcd4
 
The_Secret_Life_of_Mossahahahahahah.pptx
The_Secret_Life_of_Mossahahahahahah.pptxThe_Secret_Life_of_Mossahahahahahah.pptx
The_Secret_Life_of_Mossahahahahahah.pptx
sambal5
 
Stainless Steel Wardrobes from Verantes Living
Stainless Steel Wardrobes from Verantes LivingStainless Steel Wardrobes from Verantes Living
Stainless Steel Wardrobes from Verantes Living
Verantes Living
 
kjugyfdtryuytrdtfyugtfdxghjgfdial algorithm.pptx
kjugyfdtryuytrdtfyugtfdxghjgfdial algorithm.pptxkjugyfdtryuytrdtfyugtfdxghjgfdial algorithm.pptx
kjugyfdtryuytrdtfyugtfdxghjgfdial algorithm.pptx
vemuripraveena2622
 
FW26-27 Fashion Key Items Trend Book Peclers Paris
FW26-27 Fashion Key Items Trend Book Peclers ParisFW26-27 Fashion Key Items Trend Book Peclers Paris
FW26-27 Fashion Key Items Trend Book Peclers Paris
Peclers Paris
 
Chromatic house a case study presentation arch.pptx
Chromatic house a case study presentation arch.pptxChromatic house a case study presentation arch.pptx
Chromatic house a case study presentation arch.pptx
maheshwarigarvit2006
 
683hahhagsvjahshhshsgshhsgsgshhahsggusdf
683hahhagsvjahshhshsgshhsgsgshhahsggusdf683hahhagsvjahshhshsgshhsgsgshhahsggusdf
683hahhagsvjahshhshsgshhsgsgshhahsggusdf
pragyapatle74
 
CapCut Overlay GuideCapCut Overlay GuideCapCut Overlay Guide
CapCut Overlay GuideCapCut Overlay GuideCapCut Overlay GuideCapCut Overlay GuideCapCut Overlay GuideCapCut Overlay Guide
CapCut Overlay GuideCapCut Overlay GuideCapCut Overlay Guide
albertopamatian
 
Chapter 5 - 2,Chapter 5 - 2,Chapter 5 - 2
Chapter 5 - 2,Chapter 5 - 2,Chapter 5 - 2Chapter 5 - 2,Chapter 5 - 2,Chapter 5 - 2
Chapter 5 - 2,Chapter 5 - 2,Chapter 5 - 2
NaveedRehman55
 
Presentation3_architectural presentation case studypptx
Presentation3_architectural presentation case studypptxPresentation3_architectural presentation case studypptx
Presentation3_architectural presentation case studypptx
maheshwarigarvit2006
 
Poster Design Principles lesson for Kids
Poster Design Principles lesson for KidsPoster Design Principles lesson for Kids
Poster Design Principles lesson for Kids
emiliechingwork
 
Digital Poster PPT.pptx..............................
Digital Poster PPT.pptx..............................Digital Poster PPT.pptx..............................
Digital Poster PPT.pptx..............................
AhmedAboElSeoud3
 
最新版美国北密歇根大学毕业证(NMU毕业证书)原版定制
最新版美国北密歇根大学毕业证(NMU毕业证书)原版定制最新版美国北密歇根大学毕业证(NMU毕业证书)原版定制
最新版美国北密歇根大学毕业证(NMU毕业证书)原版定制
Taqyea
 
(18+ CLIP!) Sophie Rain Spiderman Viral Video Clip Sophie Rain Original Video
(18+ CLIP!) Sophie Rain Spiderman Viral Video Clip Sophie Rain Original Video(18+ CLIP!) Sophie Rain Spiderman Viral Video Clip Sophie Rain Original Video
(18+ CLIP!) Sophie Rain Spiderman Viral Video Clip Sophie Rain Original Video
jamesfolkner123
 
最新版西班牙比亚努埃瓦国际大学毕业证(UNIR毕业证书)原版定制
最新版西班牙比亚努埃瓦国际大学毕业证(UNIR毕业证书)原版定制最新版西班牙比亚努埃瓦国际大学毕业证(UNIR毕业证书)原版定制
最新版西班牙比亚努埃瓦国际大学毕业证(UNIR毕业证书)原版定制
Taqyea
 
Cora Bisignano PPH Presentation (1).pdf
Cora Bisignano PPH Presentation  (1).pdfCora Bisignano PPH Presentation  (1).pdf
Cora Bisignano PPH Presentation (1).pdf
corabisi
 
SUN PATH AND SHADOW ANGLESarchitrcture.pdf
SUN PATH AND SHADOW ANGLESarchitrcture.pdfSUN PATH AND SHADOW ANGLESarchitrcture.pdf
SUN PATH AND SHADOW ANGLESarchitrcture.pdf
14ANUSHAVPARCHI
 
Villa de'Urgell X -.pdf A single family two-story residence to be built in tw...
Villa de'Urgell X -.pdf A single family two-story residence to be built in tw...Villa de'Urgell X -.pdf A single family two-story residence to be built in tw...
Villa de'Urgell X -.pdf A single family two-story residence to be built in tw...
Manny Vesa
 
Midwifery_Led_Care_Units_Presentation.pptx
Midwifery_Led_Care_Units_Presentation.pptxMidwifery_Led_Care_Units_Presentation.pptx
Midwifery_Led_Care_Units_Presentation.pptx
rajanirprasadkrishna
 
ARTS IN DAILY LIVING-DRAWING TECHNIQUES_125650.pptx
ARTS IN DAILY LIVING-DRAWING TECHNIQUES_125650.pptxARTS IN DAILY LIVING-DRAWING TECHNIQUES_125650.pptx
ARTS IN DAILY LIVING-DRAWING TECHNIQUES_125650.pptx
christopherdada99
 
Styled_Soyabean_Milk_Presentation (1).pptx
Styled_Soyabean_Milk_Presentation (1).pptxStyled_Soyabean_Milk_Presentation (1).pptx
Styled_Soyabean_Milk_Presentation (1).pptx
ssuser1abcd4
 
The_Secret_Life_of_Mossahahahahahah.pptx
The_Secret_Life_of_Mossahahahahahah.pptxThe_Secret_Life_of_Mossahahahahahah.pptx
The_Secret_Life_of_Mossahahahahahah.pptx
sambal5
 
Stainless Steel Wardrobes from Verantes Living
Stainless Steel Wardrobes from Verantes LivingStainless Steel Wardrobes from Verantes Living
Stainless Steel Wardrobes from Verantes Living
Verantes Living
 
kjugyfdtryuytrdtfyugtfdxghjgfdial algorithm.pptx
kjugyfdtryuytrdtfyugtfdxghjgfdial algorithm.pptxkjugyfdtryuytrdtfyugtfdxghjgfdial algorithm.pptx
kjugyfdtryuytrdtfyugtfdxghjgfdial algorithm.pptx
vemuripraveena2622
 
FW26-27 Fashion Key Items Trend Book Peclers Paris
FW26-27 Fashion Key Items Trend Book Peclers ParisFW26-27 Fashion Key Items Trend Book Peclers Paris
FW26-27 Fashion Key Items Trend Book Peclers Paris
Peclers Paris
 
Chromatic house a case study presentation arch.pptx
Chromatic house a case study presentation arch.pptxChromatic house a case study presentation arch.pptx
Chromatic house a case study presentation arch.pptx
maheshwarigarvit2006
 
683hahhagsvjahshhshsgshhsgsgshhahsggusdf
683hahhagsvjahshhshsgshhsgsgshhahsggusdf683hahhagsvjahshhshsgshhsgsgshhahsggusdf
683hahhagsvjahshhshsgshhsgsgshhahsggusdf
pragyapatle74
 
CapCut Overlay GuideCapCut Overlay GuideCapCut Overlay Guide
CapCut Overlay GuideCapCut Overlay GuideCapCut Overlay GuideCapCut Overlay GuideCapCut Overlay GuideCapCut Overlay Guide
CapCut Overlay GuideCapCut Overlay GuideCapCut Overlay Guide
albertopamatian
 
Chapter 5 - 2,Chapter 5 - 2,Chapter 5 - 2
Chapter 5 - 2,Chapter 5 - 2,Chapter 5 - 2Chapter 5 - 2,Chapter 5 - 2,Chapter 5 - 2
Chapter 5 - 2,Chapter 5 - 2,Chapter 5 - 2
NaveedRehman55
 
Presentation3_architectural presentation case studypptx
Presentation3_architectural presentation case studypptxPresentation3_architectural presentation case studypptx
Presentation3_architectural presentation case studypptx
maheshwarigarvit2006
 
Poster Design Principles lesson for Kids
Poster Design Principles lesson for KidsPoster Design Principles lesson for Kids
Poster Design Principles lesson for Kids
emiliechingwork
 
Digital Poster PPT.pptx..............................
Digital Poster PPT.pptx..............................Digital Poster PPT.pptx..............................
Digital Poster PPT.pptx..............................
AhmedAboElSeoud3
 
最新版美国北密歇根大学毕业证(NMU毕业证书)原版定制
最新版美国北密歇根大学毕业证(NMU毕业证书)原版定制最新版美国北密歇根大学毕业证(NMU毕业证书)原版定制
最新版美国北密歇根大学毕业证(NMU毕业证书)原版定制
Taqyea
 
(18+ CLIP!) Sophie Rain Spiderman Viral Video Clip Sophie Rain Original Video
(18+ CLIP!) Sophie Rain Spiderman Viral Video Clip Sophie Rain Original Video(18+ CLIP!) Sophie Rain Spiderman Viral Video Clip Sophie Rain Original Video
(18+ CLIP!) Sophie Rain Spiderman Viral Video Clip Sophie Rain Original Video
jamesfolkner123
 
最新版西班牙比亚努埃瓦国际大学毕业证(UNIR毕业证书)原版定制
最新版西班牙比亚努埃瓦国际大学毕业证(UNIR毕业证书)原版定制最新版西班牙比亚努埃瓦国际大学毕业证(UNIR毕业证书)原版定制
最新版西班牙比亚努埃瓦国际大学毕业证(UNIR毕业证书)原版定制
Taqyea
 

Java script dom-cheatsheet)

  • 1. The most common DOM methods at a glance Reaching Elements in a Document Creating New Nodes document.getElementById('id'): Retrieves the element with document.createElement(element): Creates a new element the given id as an object node with the name element. You provide the name as a string. document.getElementsByTagName('tagname'): Retrieves all document.createTextNode(string): Creates a new text node elements with the tag name tagname and stores them in an array- with the node value of string. like list newNode = node.cloneNode(bool): Creates newNode as a copy Reading Element Attributes, Node Values and Other Data (clone) of node. If bool is true, the clone includes clones of all the child nodes of the original. node.getAttribute('attribute'): Retrieves the value of the node.appendChild(newNode): Adds newNode as a new (last) child attribute with the name attribute node to node. node.setAttribute('attribute', 'value'): Sets the value node.insertBefore(newNode,oldNode): Inserts newNode as a of the attribute with the name attribute to value new child node of node before oldNode. node.nodeType: Reads the type of the node (1 = element, 3 = text node.removeChild(oldNode): Removes the child oldNode from node) node. node.nodeName: Reads the name of the node (either element node.replaceChild(newNode, oldNode): Replaces the child name or #textNode) node oldNode of node with newNode. node.nodeValue: Reads or sets the value of the node (the text element.innerHTML: Reads or writes the HTML content of the given content in the case of text nodes) element as a string—including all child nodes with their attributes and Navigating Between Nodes text content. node.previousSibling: Retrieves the previous sibling node and Known browser quirks: stores it as an object. getAttribute and setAttribute are not reliable. Instead, assign node.nextSibling: Retrieves the next sibling node and stores it the property of the element object directly: obj.property = value. as an object. Furthermore, some attributes are actually reserved words, so instead node.childNodes: Retrieves all child nodes of the object and of class use className and instead of for use HTMLfor. stores them in an list. here are shortcuts for the first and last child Real DOM compliant browsers will return linebreaks as text nodes in node, named node.firstChild and node.lastChild. the childNodes collection, make sure to either remove them or test node.parentNode: Retrieves the node containing node. for the nodeType. Assembled by Christian Heilmann (http://wait-till-i.com), licensed Creative Commons Attribution (http://creativecommons.org/licenses/by/3.0/). Enjoy.