Get the text of an li element
Posted
by Deepak Prasanna
on Stack Overflow
See other posts from Stack Overflow
or by Deepak Prasanna
Published on 2010-03-17T08:17:36Z
Indexed on
2010/03/17
8:21 UTC
Read the original article
Hit count: 359
JavaScript
|html
<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?
© Stack Overflow or respective owner