What is the difference between innerHTML
, innerText
and childNodes[].value
in JavaScript?
The only difference between innerText
and innerHTML
is that innerText
insert string as it is into the element, while innerHTML
run it as html content.
const ourstring = 'My name is Satish chandra Gupta.';
document.getElementById('innertext').innerText = ourstring;
document.getElementById('innerhtml').innerHTML = ourstring;
.name{
color:red;
}
Inner text below. It inject string as it is into the element.
Inner html below. It renders the string into the element and treat as part of html document.