日期:2014-05-16 浏览次数:20336 次
function ges( p ){ this.pos = p;//container; this.currentClass='current'; this.currentLink = null; }; ges.prototype={ init:function(){ if( !document.getElementById || !document.createTextNode ){ return; } var navId = document.getElementById( this.pos ); if( !navId ){ return; } var navLinks = navId.getElementsByTagName( 'a' ); alert( navLinks.length ); for( var i=0; i<navLinks.length-1; i++ ){ if( this.currentLink != null ){ this.currentLink = navLinks[1]; } DOMHelp.addEvent( navLinks[i], 'click', this.getTarget, false ); } if( !this.currentLink ){ this.currentLink = navLinks[1]; this.showBg( this.currentLink ); } }, getTarget:function( e ){ var tar = DOMHelp.getTarget( e ); this.showBg( tar ); }, showBg:function( o ){ DOMHelp.cssjs( 'remove', this.currentLink, ges.currentClass ); DOMHelp.cssjs( 'add', o, this.currentClass ); this.currentLink = o; } };
<script type="text/javascript"> var n = new ges( 'nav' ); DOMHelp.addEvent( window, 'load', n.init, false ); </script>