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/
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn