SyntaxFix
Write A Post
Hire A Developer
Questions
Alternatively, you can also pass the li element itself to your myfunction function as shown:
function myfunction(ctrl) { var TextInsideLi = ctrl.getElementsByTagName('p')[0].innerHTML; }
and in your HTML, <li onclick="myfunction(this)">
<li onclick="myfunction(this)">