Get the text of an li element
- by Deepak Prasanna
<ul class="leftbutton" >
<li id="menu-selected">Sample 1</li>
<li>Sample 2</li>
<li>Sample 3</li>
<li>Sample 4</li>
<li>Sample 5</li>
</ul>
I want to get the text of the li item which the id="menu-selected".
Right now I am doing something like
document.getElementById('menu_selected').childNodes.item(0).nodeValue
Is there any simpler way of doing the same?