1.3.5 - Getting and Settings DOM Node Values Flashcards
Which properties do we have for getting and setting Elements Nodes
.innerHTML
.innerText
.textContent
.outerHTML
Which properties do we have for getting and setting Text Nodes
.data
.nodeValue
.innerHTML for what is used?
Element Nodes or Text Nodes
Element Nodes
.innerText for what is used?
Element Nodes or Text Nodes
Element Nodes
.textContent for what is used?
Element Nodes or Text Nodes
Element Nodes
.outerHTML for what is used?
Element Nodes or Text Nodes
Element Nodes
.data for what is used?
Element Nodes or Text Nodes
Text Nodes
.nodeValue for what is used?
Element Nodes or Text Nodes
Text Nodes
.innerHTML What returns?
returns all markup inside the …, without the … (it gets the descendant)
returns all markup inside the selected area, without the wrapper that we selected (it gets the descendant)
.innerHTML what returns?
all the markup inside the selected area, without the wrapper, and with their descendants?
YES
.innerHTML what returns?
It´s true to say that it will return the HTML markup with the wrapper that we select?
NO
returns all markup inside the selected area, WITHOUT the wrapper that we selected (it gets the descendant)
.innerHTML what return?
returns all markup inside the selected area, without the wrapper that we selected (it gets the descendant)
.innerHTML
When setting content, it change the DOM and the source code?
YES, it changes the DOM
NO, it not change the source code
.innerHTML
What is a good practice, when we are using .innerHTML for setting content, if we are appending a lot of content to it?
To append the content, into a new variable like:
var newVar = ‘title’;
newVar += ‘More content’;
contenido.innerHTML = newVar;
.innerHTML
It’s possible to append content directly on the property?
YES
.innerHTML
If we had which nodes … that has a child text node, that includes the characters &, <, >, will returns what characters?
the nodes that need to have a child text node are:
div, span, noembed
returned characters:
&, <, >
.innerHTML
What can we use to get a correct copy of the text nodes that are child of elements: div, span, noembed , that has the characters:
&, <, >
We can use .textContent
Why we need to use .textContent with nodes elements like:
div, span, noembed
that has child text node, that includes the characters:
&, <, >
Because if we use .innerHTML will return the characters &, <, >
.innerText is it true that will return the following?
Returns all the text, without formatting and markups. It’s like if the user would highlighted the contents of the element with the cursor and then copied to the clipboard
YES
.innerText?
Returns …, without formatting and markups.
Returns all the text, without formatting and markups
.innerText?
It is true that will return all the text with the proper formatting and markups?
NO
It will return all the text, without formatting and markups
.innerText
We can say that it’s like if the user do what?
Would highlight the content of the element with the cursor and then copied to the clipboard.
.innerText?
What happens when we have a css rule “display: none”
Using .innerText, that section will be ignored, not returned
.innerHTML parse content as HTML, and takes longer to run?
What will be the output?
YES
output: text/HTML
.innerText will take styles into consideration? what it means?
YES it takes styles into consideration
It means that, it won´t get hidden text for instance.
.textContent
Returns all the content without interfering with css rules?
YES
.textContent
If the element is a document, a docType, what it returns?
returns null
document.textContent // null
.textContent
to grab all text for the whole document we can use what?
document.documentElement.textContent