inner content javascript code example

Example 1: change innerhtml

document.getElementById("p1").innerHTML = "New text!";

Example 2: textcontent in javascript

// The textContent property sets or returns the text content of the specified node

// read text content from id .. 
let text = document.getElementById('id').textContent;
console.log(text);

// change text content of id .. 
document.getElementById('id').textContent = "text is changed now !";

Example 3: inner content

document.getElementById("myBtn").textContent;
document.getElementById("myBtn").innerHTML;
document.getElementById("myBtn").innerText;
// js dont have innerContent