Jump to content

Update a Divs content with DOM.


GB_001

Recommended Posts

Okay, it to partially work.

The text appears but the html does not appear.

<html>
<head>



<script language="javascript" type="text/javascript"> 
function go(){
document.getElementById('wow').innerHTML = <html><head></head> <body bgcolor="black"> RAWR</body></html>;
}</script>
</head>
<body>

<div id='wow'><input type='button' onClick="go();" value="BAM">
</div>

</body>
</html>

innerHTML refers to the contents of an element, not a whole html page.

You would not do

<div id='wow'><html><head></head> <body bgcolor="black"> RAWR</body></html></div>

but instead just

<div id='wow'>RAWR</div>

 

 

Use something like

document.getElementById('wow').innerHTML = 'RAWR';
document.getElementById('wow').style.backgroundColor = 'green';

inside the go() function.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.