Get Value or Text of a List item (<UL> or <OL>) - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Ul

Description

Get Value or Text of a List item (<UL> or <OL>)

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//  w  w  w .j  a  v a  2 s . c om
var li = document.getElementById("myLi")
console.log(li.textContent || li.innerText);
    }

      </script> 
   </head> 
   <body> 
      <ul> 
         <li id="myLi">Hello, world</li> 
      </ul>  
   </body>
</html>

Related Tutorials