Javascript examples for DOM:Element textContent
Get text content from node via textContent attribute
<html lang="en"> <head> <title>Document</title> <script> function jsTest()/* w w w . j a va 2s .c o m*/ { var x = document.getElementById("fruits"); var y = x.children[2].textContent; console.log(y); } </script> </head> <body> <ul id="fruits"> <li>Apple</li> <li>Banana</li> <li>Pear</li> <li>Orange</li> </ul> <button onclick="jsTest()">TRY</button> </body> </html>