Maelstorm Posted May 13, 2009 Share Posted May 13, 2009 Consider the following code:<html><head><title>Test</title><script language="JavaScript" type="text/javascript" application="yes">var idData = "item";</head><body><span id="item"></span></body></html>How do you access, say item.innerHTML by referencing idData? I tried using idData.innerHTML but the interpreter throws an error. Any ideas? Link to comment Share on other sites More sharing options...
jcarle Posted August 1, 2009 Share Posted August 1, 2009 document.getElementById(idData).innerHTML will do the trick. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now