I want to have the text value from a inside a
element.
html:
-
HTML:
<ul>
<li onclick="myfunction(this)">
<span></span>
<p>This Text</p>
</li>
</ul>
JavaScript:
function myfunction(foo) {
var elem = foo.getElementsByTagName('p');
var TextInsideLi = elem[0].innerHTML;
}
change your html to the following:
<ul>
<li onclick="myfunction()">
<span></span>
<p id="myParagraph">This Text</p>
</li>
</ul>
then you can get the content of your paragraph with the following function:
function getContent() {
return document.getElementById("myParagraph").innerHTML;
}
Use jQuery:
$("li").find("p").html()
should work.