Variable reference, rather then replica.
Posted: Fri Jan 12, 2007 11:05 pm
I'm looking for a way to define a javascript variable and have it equal the reference of another object, not just create a new object like it. E.g:
I'm not using var keyword 'cause I'm declaring it as global. But what I'm wanting here is that Myvar equals to the reference of all the elements that acquire the id, "theID", if possible. What I mean by reference is that if one or more elements are loaded with the id as "theID" then Myvar wouldn't need to reassign it's value, because it would just be a reference. So every time I write "Myvar.style.etc" it'd be just like writing "document.getElementById("theID").style.etc".
Is this possible in anyway?
Code: Select all
Myvar = document.all? document.all["theID"] : document.getElementById? document.getElementById("theID") : "";
Is this possible in anyway?