function toggleMe(a){
// create a function called toggleMe that takes a named parameter a.
// since the function is not assigned to a variable, it is globally
// scoped and rests in the window object. (window.toggleMe)
var e =document.getElementById(a);
// grabs an element named a (therefore a should be a string) from the DOM and
// assigns it to the variable window.toggleMe.e
if(!e)return true;
// check to see if e exists before continuing
if(e.style.display=="none"){
// check to see if e has the css property display:none
e.style.display="block"
// if it does, set it's display to block, so that it become visible.
} else {
// otherwise, make it invisible.
e.style.display="none"
}
// exit... nothing special here.
return true;
}
正确的,但这种风格的注释(在同一行)是难以阅读。 – pavium 2009-11-20 03:29:17