[Javascript] javascript and id's
Paul Novitski
paul at novitskisoftware.com
Tue Oct 4 12:29:56 CDT 2005
At 10:20 AM 10/4/2005, Anthony Ettinger wrote:
>Yes, this is what I came up with:
>
>function changeAttrib(id, attrib, newValue)
>{
> var elemObj = document.getElementById(id);
> elemObj.setAttribute(attrib, newValue);
>
> return true;
>}
Looks good. But why are you returning true? You don't have to,
especially in a case like this where your function ALWAYS returns the
same value. Unlike some other languages (VBscript, for example),
JavaScript lets you treat a function like a sub call, that is:
x = doSomething(y);
or simply:
doSomething(y);
Paul
More information about the Javascript
mailing list