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)">
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…