We know that the value of the string contained in the node can be obtained through the innerHTML attribute that comes with the browser. For example, the following nodes:
Copy the code via
var obj=document.getElementById("test" );alert(obj.innerHTML);//The returned value is i'm strong
If I want to get the text value of the node, the label will not be included. string, what should I do? The text value here is: i'm strong
//Non-Mozilla browser: obj.innerText;//Other browsers obj.firstChild.nodeValue;
First provide a general method to solve compatibility issues:
The complete code is as follows:
Code
]
Let FireFox support The implementation code of innerText
Please indicate the source for reprinting: http://www.cnblogs.com/wbkt2t/