Jump to content
xisto Community
Sign in to follow this  
electriic ink

How Do You Make Text In A <div> Change When You Click On A Link? something to do with jvascript

Recommended Posts

Thats pretty easy.Use the getElementById() function of Java Script.Then Change the text by using innerHTML function.If you want to call it by anchor call a function which does the above thing.

Share this post


Link to post
Share on other sites

Thanks electron but after some researching it appears that innerHTML is an IE thing. Is there any function which cross-browser compatible? Thanks....

Share this post


Link to post
Share on other sites

innerHTML works for me, and i'm using Opera.

<input type="button" value="Click" onclick="document.getElementById('a').innerHTML='newtext'"/><span id="a">text</span>

Share this post


Link to post
Share on other sites

It works for firefox as well. :) Oh well, guess you can't believe half of what you read on the internet. Maybe it had Microsoft origins or something. Thank you electron and truefusion....

Share this post


Link to post
Share on other sites

Is there a way to do this within a DIV rather than a form item? I need to use HTML and have the updated text realise this:function Web1(){ var MyElement = document.getElementById("MyTextBox"); MyElement.value = "<h2>header</h2><p>text2</p>"; return true;}thanks

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.