Jump to content

Changing Div Tag With Js


higuy001
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...