[Javascript] GetElementByElement?

Simeon Willbanks simeon at simeons.net
Wed Mar 3 12:58:10 CST 2004


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 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20040303/d84f1268/attachment.htm>


More information about the Javascript mailing list