[Javascript] GetElementByElement?
Peter Brunone
peter at brunone.com
Wed Mar 3 13:24:27 CST 2004
Hi Simeon,
I'm not sure why getElementById won't work for you. If you want
to refer to the body, why not just document.body? Let me know if I've
misunderstood.
Cheers,
Peter Brunone
-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of Simeon Willbanks
Hello All,
I grabbed a bit of code from a dhtml kitchen tutorial. I am trying to
modify it to fit my needs. Below is the original code
function setStyle(obj,style,value){
getRef(obj).style[style]= value;
}
function getRef(obj){
return (typeof obj == "string") ?
document.getElementById(obj) : obj;
}
You can then use an onclick event to set a style by id, and it works
beautifully.
<p class="link" onclick="setStyle('fixed','visibility','hidden')">Close
The Ad</p>
What I need to do is change and element property along with an id
property. In other words, set a div to display:none; and change the an
element like body: padding-bottom: 0;
I don't know if a function exists like getElement? Maybe than I could
write a function to recognize the body element css properties in order
to switch the properties? Has anyone tired to do this before? Any help
would be appreciated.
Thanks,
Simeon
More information about the Javascript
mailing list