innerHTML or innerText:-
syntax:- document.getElementById("demo").innerHTML
किसी HTML एलिमेंट को एक्सेस करने के लिए, आप document.getElementById(id) मेथड का उपयोग कर सकते हैं।
HTML एलिमेंट को पहचानने के लिए id एट्रिब्यूट का उपयोग करें।
फिर उस HTML एलिमेंट की कंटेंट बदलने के लिए innerHTML प्रॉपर्टी का उपयोग करें।
एक ही id का उपयोग एक से अधिक एलिमेंट पर नहीं कर सकते।
code:-
<!DOCTYPE html>
<html>
<body>
<p id="demo">Hello World</p>
<script>
{
document.getElementById("demo").innerHTML = "New Text!";
}
</script>
</body>
</html>
innerHTML or innerText:-
syntax:- document.getElementById("demo").innerHTML
To access an HTML element, you can use the document.getElementById(id) method.
Use the id attribute to identify the HTML element.
Then, use the innerHTML property to change the content of that HTML element.
You cannot use the same id on more than one element.
That is, all ids on a page must be unique.
If you give the same id to two elements, getElementById will not work correctly.
code:-
<!DOCTYPE html>
<html>
<body>
<p id="demo">Hello World</p>
<script>
{
document.getElementById("demo").innerHTML = "New Text!";
}
</script>
</body>
</html>