2021-05-05 09:21:37 -04:00
<!DOCTYPE html>
< html >
< body >
< h3 > Differences between innerText and textContent.< / h3 >
< p id = "demo" > This p element contains a < span style = "display:none" > hidden span element< / span > and a < span > visible span element< / span > .< / p > kkkk
< button onclick = "getTextContent()" > Get textContent< / button >
< button onclick = "getInnerText()" > Get innerText< / button >
< p > < strong > Note:< / strong > The textContent property is not supported in Internet Explorer 8 and earlier, and the innerText property is not supported in IE9 and earlier.< / p >
< p id = "demo" > < / p >
< script >
function getTextContent() {
2021-11-10 11:33:59 -05:00
window.alert(document.getElementById("demo").textContent)
2021-05-05 09:21:37 -04:00
}
function getInnerText() {
2021-11-10 11:33:59 -05:00
window.alert(document.getElementById("demo").innerText)
2021-05-05 09:21:37 -04:00
}
< / script >
< / body >
< / html >