
这款仿Windows风格的选项卡,带有灰色的立体感,示例内容是用JS控制输出,只是为了演示功能,你在用的时候完全可以去掉的。
运行效果截图如下:

在线演示地址如下:
http://demo.jb51.net/js/2015/js-f-windows-style-tab-demo/
具体代码如下:
选项卡 function CreateTab(tab_width,tab_height,parent_obj){ var newtab=document.createElement("UL"); newtab.className="tab"; parent_obj.appendChild(newtab); Tab.call(newtab); newtab.style.width=tab_width+"px"; newtab.style.height=tab_height+"px"; return newtab; } function Tab(){ var this_tab=this; this.selected_page; this.page_names=new Array(); this.page_contents=new Array(); this.Select=function(){ this_tab.selected_page.className=""; this.className="selected"; this_tab.selected_page=this; } this.NewPage=function(page_name){ var newpage=document.createElement("LI"); newpage.onclick=this.Select; newpage.innerHTML=""+page_name+""; this.appendChild(newpage); newpage.lastChild.style.width=parseInt(this.style.width)-2+"px"; newpage.lastChild.style.height=parseInt(this.style.height)-24+"px"; this.page_names.push(newpage.firstChild); this.page_contents.push(newpage.lastChild); return newpage; } this.SetChecked=function(page_index){ if(page_index>-1&&this.childNodes.length>page_index){ this.selected_page=this.childNodes[page_index]; this.selected_page.className="selected"; } } } script>
希望本文所述对大家JavaScript程序设计有所帮助。
