Difference between innerText, innerHTML, and childNodes[].value?

前端 未结 11 1250
别跟我提以往
别跟我提以往 2020-11-22 06:57

What is the difference between innerHTML, innerText and childNodes[].value in JavaScript?

11条回答
  •  有刺的猬
    2020-11-22 07:38

    var element = document.getElementById("main");
    var values = element.childNodes[1].innerText;
    alert('the value is:' + values);
    

    To further refine it and retrieve the value Alec for example, use another .childNodes[1]

    var element = document.getElementById("main");
    var values = element.childNodes[1].childNodes[1].innerText;
    alert('the value is:' + values);
    

提交回复
热议问题