Jump to content

Accessing a dynamic id in Javascript?


Recommended Posts

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

  • 2 months later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...