Get paragraph text inside an element

后端 未结 9 548
孤独总比滥情好
孤独总比滥情好 2021-02-03 19:21

I want to have the text value from a

inside a

  • element.

    html:

  • 9条回答
    •  暖寄归人
      2021-02-03 20:07

      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,

    提交回复
    热议问题