新手求教:function最后为什么要return ture 不理解求指点
function prepareGallery(){
if(!document.getElementsByTagName) return false;
if(!document.getElementById) return false;
if(!document.getElementById("imagegallery")) return false;
var gallery=document.getElementById("imagegallery");
var links=gallery.getElementsByTagName("a");
for(var i=0;i<links.length;i++){
links[i].onclick=function(){
return !showPic(this);
}
}
}
function showPic(whichpic){
//检查id="placeholder",id="description"是否存在
if(!document.getElementById("placeholder")) return false;
var placeholder=document.getElementById("placeholder");
var source=whichpic.getAttribute("href");
if(placeholder.nodeName!="IMG") return false;
placeholder.setAttribute("src",source);
if(document.getElementById("description")){
var description=document.getElementById("description");
var img_text=whichpic.getAttribute("title")?whichpic.getAttribute("title"):" ";
if(description.firstChild.nodeType==3){
description.firstChild.nodeValue=img_text;
}
}
return true;
}
这里为什么要返回一个真,不理解,如果返回真,那前面的return !showPic(this);不就一直都是假了吗?求高手 指点