欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

將兩個div左右并列顯示并實現(xiàn)點擊標(biāo)題切換內(nèi)容

 更新時間:2013年10月22日 17:20:33   作者:  
將兩個div左右并列顯示并實現(xiàn)點擊標(biāo)題切換內(nèi)容的效果,接下來為大家詳細介紹下js中時如何實現(xiàn)的,感興趣的朋友不要錯過
復(fù)制代碼 代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN" xml:lang="zh-CN">
<head>
<title>選項卡</title>
<style type="text/css">
<!--
* { margin:0; padding:0; font-size:12px; font-weight:normal; }
.jj { font-weight:bolder!important; }
.box { border-top-color:#c00!important; }
.pr { color:#060!important; }
#tab01 { position:relative; width:336px; height:88px; padding-top:15px; margin:50px; overflow:hidden; }
#tab01 h3 { position:relative; z-index:2; float:left; height:14px; padding:0 7px 0 8px; margin-left:-1px; border-left:solid 1px #ccc; border-right:solid 1px #fff; text-align:center; background:#fff; cursor:pointer; }
#tab01 h3.up { height:18px; padding:5px 7px 0 7px; margin:-6px 0 0 0; border:solid #ccc; border-width:1px 1px 0; color:#c00; }
#tab01 div { display:none; position:absolute; left:0; top:32px; z-index:1; width:324px; height:54px; padding:5px; border:solid 1px #ccc; color:#666; }
#tab01 div.up { display:block; }
#tab02 { position:relative; width:200px; margin:50px; border:solid #ccc; border-width:0 1px 1px; }
#tab02 h4 { height:18px; line-height:18px; border:solid #ccc; border-width:1px 0; margin-bottom:-1px; text-align:center; background:#f6f6f6; cursor:pointer; }
#tab02 h4.up { color:#c00; }
#tab02 ol { display:none; height:54px; padding:5px; color:#666; }
#tab02 ol.up { display:block; }
#tab03 { position:relative; width:100px; margin:50px; }
#tab03 h3 { position:relative; z-index:1; height:16px; padding-top:4px; margin-bottom:-1px; border:solid #ccc; border-width:1px 0 1px 1px; text-align:center; font-family:宋體; background:#eee; cursor:pointer; }
#tab03 h3.up { z-index:3; color:#c00; background:#fff; }
#tab03 div.tab { display:none; position:absolute; left:99px; top:0; z-index:2; width:300px; height:200px; padding:5px; border:solid 1px #ccc; color:#666; }
#tab03 div.tab.up { display:block; }
-->
</style>
</head>
<body>
<div id="tab01">
<h3>首頁</h3>
<div class="jj"><p>嘿嘿,無視div原始class值。</p></div>
<h3 class="pr">測試</h3>
<div><p>繼續(xù)無視h3原始class值。</p></div>
<h3>無聊</h3>
<div><p>h3沒有值也可以~</p></div>
<h3 class="box">傻蛋</h3>
<div><p>div沒有值一樣可以~</p></div>
</div>
<div id="tab02">
<h4>首頁</h4>
<ol class="pr"><li>嘿嘿,無視容器原始class值。</li></ol>
<h4 class="box">測試</h4>
<ol><li>繼續(xù)無視h3原始class值。</li></ol>
<h4>無聊</h4>
<ol><li>h3沒有值也可以~</li></ol>
<h4 class="bb">傻蛋</h4>
<ol><li>div沒有值一樣可以~</li></ol>
</div>
<div id="tab03">
<h3>首頁</h3>
<div class="tab"><p>嘿嘿,無視h3原始class值。</p></div>
<h3>測試</h3>
<div class="tab wushi"><p>繼續(xù)無視div原始class值。</p></div>
<h3>無聊</h3>
<div class="tab"><p>h3沒有值也可以~</p></div>
<h3 class="box">傻蛋</h3>
<div class="tab tab123"><p>class值相似一樣也可以~</p><div><p>指定class后,即時再多一個div也行。</p></div></div>
</div>
<script type="text/javascript">
<!--
function Pid(id,tag){
if(!tag){
return document.getElementById(id);
}
else{
return document.getElementById(id).getElementsByTagName(tag);
}
}

function tab(id,hx,box,iClass,s,pr){
var hxs=Pid(id,hx);
var boxs=Pid(id,box);
if(!iClass){ // 如果不指定class,則:
boxsClass=boxs; // 直接使用box作為容器
}
else{ // 如果指定class,則:
var boxsClass = [];
for(i=0;i<boxs.length;i++){
if(boxs[i].className.match(/\btab\b/)){// 判斷容器的class匹配
boxsClass.push(boxs[i]);
}
}
}
if(!pr){ // 如果不指定預(yù)展開容器,則:
go_to(0); // 默認展開序列
yy();
}
else {
go_to(pr);
yy();
}
function yy(){
for(var i=0;i<hxs.length;i++){
hxs[i].temp=i;
if(!s){// 如果不指定事件,則:
s="onmouseover"; // 使用默認事件
hxs[i][s]=function(){
go_to(this.temp);
}
}
else{
hxs[i][s]=function(){
go_to(this.temp);
}
}
}
}
function go_to(pr){
for(var i=0;i<hxs.length;i++){
if(!hxs[i].tmpClass){
hxs[i].tmpClass=hxs[i].className+=" ";
boxsClass[i].tmpClass=boxsClass[i].className+=" ";
}
if(pr==i){
hxs[i].className+=" up"; // 展開狀態(tài):標(biāo)題
boxsClass[i].className+=" up"; // 展開狀態(tài):容器
}
else {
hxs[i].className=hxs[i].tmpClass;
boxsClass[i].className=boxsClass[i].tmpClass;
}
}
}
}
tab("tab01","h3","div","","onclick",2); tab("tab02","h4","ol");tab("tab03","h3","div","tab");
//-->
</script>
</body>
</html>

相關(guān)文章

  • JavaScript+H5實現(xiàn)微信搖一搖功能

    JavaScript+H5實現(xiàn)微信搖一搖功能

    這篇文章主要為大家詳細介紹了JavaScript+H5實現(xiàn)微信搖一搖功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • js 得到文件后綴(通過正則實現(xiàn))

    js 得到文件后綴(通過正則實現(xiàn))

    使用js獲取文件的后綴,有個不錯的正則,大家可以借用下,具體如下,感興趣的朋友可以參考下哈,希望對大家有所幫助
    2013-07-07
  • JS中的Map對象用法及說明

    JS中的Map對象用法及說明

    這篇文章主要介紹了JS中的Map對象用法及說明,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-02-02
  • JS的數(shù)組迭代方法

    JS的數(shù)組迭代方法

    這篇文章主要介紹了JS的數(shù)組迭代方法,實例分析了javascript使用數(shù)組迭代的相關(guān)技巧,代碼中備有較為詳細的注釋便于理解,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-02-02
  • javascript函數(shù)的4種調(diào)用方式與this的指向

    javascript函數(shù)的4種調(diào)用方式與this的指向

    本文主要介紹了javascript函數(shù)的4種調(diào)用方式與this(上下文)的指向,文中有詳細的代碼示例,感興趣的同學(xué)可以參考閱讀一下
    2023-05-05
  • JS中的數(shù)組的sort方法使用示例

    JS中的數(shù)組的sort方法使用示例

    sort會調(diào)用每一項的toString方法進行比較,下面為大家介紹下JS中數(shù)組sort方法的具體使用
    2014-01-01
  • JS實現(xiàn)“全選”和

    JS實現(xiàn)“全選”和"全不選"功能代碼實例

    這篇文章主要介紹了JS實現(xiàn)“全選”和"全不選"功能代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-02-02
  • 詳解ES6 Symbol 的用途

    詳解ES6 Symbol 的用途

    Symbol 唯一的用途就是標(biāo)識對象屬性,表明對象支持的功能。 這篇文章給大家介紹ES6 Symbol 的用途,感興趣的朋友跟隨小編一起看看吧
    2018-10-10
  • JavaScript對Json的增刪改屬性詳解

    JavaScript對Json的增刪改屬性詳解

    下面小編就為大家?guī)硪黄狫avaScript對Json的增刪改屬性詳解。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-06-06
  • JavaScript控制輸入框中只能輸入中文、數(shù)字和英文的方法【基于正則實現(xiàn)】

    JavaScript控制輸入框中只能輸入中文、數(shù)字和英文的方法【基于正則實現(xiàn)】

    這篇文章主要介紹了JavaScript控制輸入框中只能輸入中文、數(shù)字和英文的方法,基于正則驗證實現(xiàn)字符輸入限制功能,具有一定參考借鑒價值,需要的朋友可以參考下
    2017-03-03

最新評論