//innerText //gives the plain text and thus, removes all other elements in that paragraph document.querySelector("p").innerText //textContent //gives the text with spacing taking into account the original mark up of the text //return every element document.querySelector("p").textContent //innerHTML //gives the text + markups document.querySelector("p").innerHTML //Manipulating //with innerText document.querySelector("p").innerHTML = "<i>Something!</i>" // <i>Something!</i> //with innerHTML document.querySelector("p").innerHTML = "<i>Something!</i>" // Something! (in italic)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter