Jump to content

Changing Div Tag With Js


higuy001

Recommended Posts

Does anyone know the code to change a <div> tag's content? I've tried using

function divMath() {var div = document.getElementById("content");var txt = "<A href=\"http://miniwidgit.webs.com/Math.wdgt.zip\">Math Widgit</A><br><input type=\"button\" value=\"Info...\" onClick=\"att();\"><br><a href=\"http://miniwidgit.webs.com/MathLarge.wdgt.zip\">Math Widgit Large</a>";div.value = txt;}

but this doesn't work.Am I doing anything wrong? Did I miss a semicolon? Can anyone help? :)HiGuy

Link to comment
Share on other sites

Use the innerHTML property, not the value property.
That doesn't seem to work though.Is anything else wrong?
function divMath() {var div = document.getElementById("content");var txt = "<A href=\"http://miniwidgit.webs.com/Math.wdgt.zip\">Math Widgit</A><br><input type=\"button\" value=\"Info...\" onClick=\"att();\"><br><a href=\"http://miniwidgit.webs.com/MathLarge.wdgt.zip\">Math Widgit Large</a>";div.innerHTML = txt;}

<a href="#" onClick="divMath();" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','TabLeft2.png',1)"><img src="TabLeft.png" name="Image1" width="100" height="50" border="0"></a>

<div name="content"></div>

HiGuy

Link to comment
Share on other sites

It's called "getElementById" because you search for the element by the ID.Use this: <div id="content"></div>
Oooohhhhhhhhhhhhhh! :( :)I SO didn't realize that.Wow.I am dumb. :) :)Thanks! It works!HiGuy
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...