what is .innerHTML in javascript?

Posted by Maheshvishnu under JavaScript on 9/24/2012 | Points: 10 | Views : 1508 | Status : [Member] | Replies : 5
what is .innerHTML in javascript?


Thanks in advance.

mahesh


Responses

Posted by: Vikash on: 9/24/2012 [Member] Starter | Points: 25

Up
0
Down
It means everything(other element, any text, or any thing) inside the openning and closing tag of that element...

if found helpful plz mark as answer.....

Regards,
Vikash Pathak

Maheshvishnu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pgayath on: 9/24/2012 [Member] Starter | Points: 25

Up
0
Down
Mahesh:

The innerHTML property can be used to change the document's HTML or the page's content without refreshing the page. This can make your website feel quicker and more responsive to user input.

The innerHTML property is used along with getElementById in the JavaScript code to refer to an HTML element and change its contents.

Syntax:

document.getElementById('{ID of element}').innerHTML = '{content}';


Maheshvishnu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pgayath on: 9/24/2012 [Member] Starter | Points: 25

Up
0
Down
Mahesh:

Please let me know if you need further details.

Thanks and Regards,
Gayathri P

Maheshvishnu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/24/2012 [Member] Bronze | Points: 25

Up
0
Down
h HTML element has an innerHTML property that defines both the HTML code and the text that occurs between that element's opening and closing tag.

Syntax:-
var content = element.innerHTML;

<html>
<head></head>
<body>
<div id="txt">
<script id="txt0"> x=0 </script>
<noembed id="txt1"> 1 </noembed>
<noframes id="txt2"> 2 </noframes>
<noscript id="txt3"> 3 </noscript>
<div id="txt4"> 4 </div>
<div>
<noscript id="txt5"> 5 </noscript>
</div>
<span id="txt6"> 6 </span>
</div>
<div id="innerHTMLtxt"></div>
<div id="textContenttxt"><div>
<script>
for (i=0;i<7;i++){
x="txt"+i;
document.getElementById(x).firstChild.nodeValue='&<>'
}

document.getElementById("innerHTMLtxt").textContent=document.getElementById("txt").innerHTML
document.getElementById("textContenttxt").textContent=document.getElementById("txt").textContent
</script>
</body>
</html>

Maheshvishnu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/25/2012 [Member] Bronze | Points: 25

Up
0
Down
Please mark as answer if it helpful to you..That helps others who search the same..

Maheshvishnu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response