var tabs=function(){ function tag(name,elem){ return (elem||document).getElementsByTagName(name); } //获得相应ID的元素 function id(name){ return document.getElementById(name); } function first(elem){ elem=elem.firstChild; return elem&&elem.nodeType==1? elem:next(elem); } function next(elem){ do{ elem=elem.nextSibling; }while( elem&&elem.nodeType!=1 ) return elem; } return { set:function(elemId,tabId){ var elem=tag("li",id(elemId)); var tabs=tag("ul",id(tabId)); var listNum=elem.length; var tabNum=tabs.length; for(var i=0;i