get p text javascript code example
Example 1: javascript set text of div
document.getElementById("content").innerHTML = "whatever";
Example 2: textcontent in javascript
let text = document.getElementById('id').textContent;
console.log(text);
document.getElementById('id').textContent = "text is changed now !";
Example 3: javascript get text from paragraph
function getContent() {
return document.getElementById("myParagraph").innerHTML;
}
Example 4: set text of dom element
document.getElementById("myBtn").textContent = 'Hello World';