firstChild.nodeValue

Suppose we have a dom object whose content such as
content

In javascript, we have to get the title and text labels, generally need to do
var title = dom.getElementsByTagName ( "title");
Alert (title [0] .nodeName); // get "title"
Alert (title [0 ] .nodeValue) when, FF only get #text, while IE only get null
then check a lot of information, object text type or object element, is itself a node
on the case "title" is not a simple text content but a text node
it also has its own nodeName, but should also not be used
it should be written:
Alert (title [0] .firstChild.nodeValue); // get the "title"

On the other hand, want to turn, generate a text time, but also with create_text_node method
also uses append_child add it in the next parent node
that it is actually a node, you need to use more than once firstChild 

 

Reprinted from: https://blog.csdn.net/bananabear/article/details/1553082

Guess you like

Origin blog.csdn.net/mxk4869/article/details/94445201