I have a js script that would getElementByTagname. Then, i check it childNodes value.If i use this line of code:
var appname= name[i].childNodes[x].nodeValue;
If the nodeValue is Pang Shinichi (Away from home). The return of the script above became Pang Shinichi (). HTML tag is not being read but instead it was consider as NULL. So, i was thinking if its possible to use childNodes.nodeValue and innerHTML at once.
Any idea on this?
This is because your text is spread across several nodes. For a quick solution, use
textContentandinnerTexton the parent node instead:Internet Explorer 8 and lower will use
innerText, whilst most other browsers will usetextContent. There are slight differences between the behaviour of the two when it comes to white space, but for most use cases the results are identical.Working demo: http://jsfiddle.net/7Qsjm/