js进阶 11-22/23 js如何实现选项卡

时间:2021-09-09 07:43:51

js进阶 11-22/23 js如何实现选项卡

一、总结

一句话总结:通过索引把选项卡头的li标签和选项卡内容的div标签联系在一起,通过控制div标签的display属性可以实现选项卡的选项切换。

1、某些样式设置了,但是出不来效果的原因可能是什么?

优先级会导致某些特效出不来

现在设置的优先级低于之前的

可以通过加父标签的方式来增加优先级

2、如何增加样式的优先级?

可以通过加父标签的方式来增加优先级

3、如何实现一组标签中点某个标签,这个标签的样式改变?

动态给点的标签添加一个自己写好的激活样式

71                 oli[this.index].className="active";

4、如何消除一个元素的所有类?

dom对象的className赋空值

67                     oli[j].className="";

5、如何让一个隐藏的元素显示?

将dom对象的style的display属性设置为none

68                     li_content[j].style.display='none'

6、如何获取一个id为content的div里面的另外的div?

getElement的链式写法(因为getElement是document的方法,其实也是dom对象的方法)

57         var li_content=    document.getElementById('content').getElementsByTagName('div')

二、js如何实现选项卡

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAW4AAAC0CAYAAAC0cMZyAAAgAElEQVR4nO2dB4AURdbHX3fP7C5LBgMKKkkEBBThUEA5FbMo5pzPrOAZPnM6FTlzTuihYg53pjsF7xAQOQWUbDgDSlCCgMCyLLsz0/3Ve9Xd0zM7szsz7IK9/H9LM7Odqrq2+1+vXr2uMmzbdggAAEBoMDd3BgAAAOQHhBsAAEIGhBsAAEIGhBsAAEIGhBsAAEIGhBsAAEJGJN8DHLLl09jCNT/ulkOwABOqVLhkDPnNUSW0JURaGu5St9h1fsbfJ0baJwC5kLdwZ2dLufW0GLOwOIZbgI6+esddx1Wa4WwZJVJo1RQsm0znkHVGwy9BuUJnS6jgQV2St3Dbri2k7e2ktdXwHzEXRy9FGUwlT8STOzZ0u7F6q8sJiJCxEcJryckKPhyABk3Owh18ID2xMuqpmRxWxOpW5ZQiWFuC+GS8BWq+L/zbKbCbUdu91JDK0rtUx2tdbMa8gNCRt8VtORH9gHm+AdpybjwWG7ahDYt8b7ZctpHcLmUh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5oMPPtgXGi5jPsef//xneumll+Q77ztp0iQRw1NOOUXWZXWbpFEXws1C+NNPP9HkyZPpzTffFHHkyo0rHc4XCytXUOeffz61bt1aWiyHHHKILBnzxO8luOLK3/l8r7zyimw75phj5DsL+7777utf39NPPy1/Gw9P+I844ggqKyuT71zR7bfffrKOK7ts5ZO9xLIJN0QbVKcOx+PW8G029MjD6YlnnqOlS5bSGnVj3/qXEUqo95I3CFlh7XiCRj/3Ah184AG+L9OLYMmFa6+5iu6+70G66vLLiG/yt995V6xWFh4+x4yZs6ikUYkINL8YyunOn/8jrf5tNe2z9wCqqmIL01IW5DbUVVmokz+ZotYPTF6Dm8/6wLP4OK9//etfRWj52merVgNbe7vssouqUIbLft999524M3bffXf/+C5duoiFl35OT7h5YfHiimvYsGFy3pNOOknWX3nllXTbbbdJxcCMHj2abr31Vv8cvM8bb7whotekSRM/n9wCYNH8+eefqV27dvVSLtlga/rEE08UsWbeffddqejY4r300ktl3X/+8x868sgjpUXiVULZXDt8jXxOhq9vjz32oEWLFklrp1evXmLFP/nkk3TCCSfQRx99JNd/xRVXUHl5uX8OXnfLLbfQQw89JN+91g9XeDfeeKNUuADUJ3Um3J5o6KALg/64z0AqX18h8UyWdRq9/trr1L5De+rTZw+qqthADzz6hA6LUtvj8aQbhLK8gc8dk2Ilqe+Welj26teX7r7nPurerSutL19PTZXQ8LaFCxbS7Lnz6E9nn+me16aK8g305KhnaPilF1Hb7duKxZVIGNS4cWP1gB5HY8a8SM2bNRXLlvORUMdFrPobW8RrPTBnnHGGfJ5++unyefbZZ4uFx/uwNekJkOf7zoRf9m6l4O3P7oNffvmF3nrrLbGY2aL09h0zZgxdd911tMMOO8hxnN77778vLokLLrhAWjJeXlncuKxYmFjYN2VIHqe/zTbb0KmnnirXxp+cPl/LP/7xD8n7999/7+8frMTYBcQtGy+/wU++B7y/Q+/evcWCv+OOO+jMM89ULbB7/X25LLiik/tClSmfj8W5X79+UlkEXUdHHXWUtG5Y9LmcAKgv6tzi9h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M37dt61ED61S4GcdxfTR5ZhLCDQAAKThZfjPy8JnkFg7oW9A5ZCpfdQcAgC0Io4bfcqXOJ1KAlQ0AAPULXnkHAICQAeEGAICQAeEGAICQAeEGAICQAeEGAICQAeEGAICQAeEGAICQ8f8w2MoxFmpAZwAAAABJRU5ErkJgggA=" alt="" />

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>选项卡2</title>
<style>
*{margin:0px;padding: 0px }
body{padding: 50px}
#list{
list-style-type: none;
height: 30px;
font-size: 14px
}
#list li{
width: 80px;
margin-right: 5px;
height: 30px; line-height: 30px;
text-align: center;
border: solid green 1px;border-bottom: none;
border-radius: 5px 5px 0 0;
float: left;
cursor: pointer;
}
#content div{
width: 400px;
height: 150px;
border:1px solid green;
display: none;
background: rgba(100,50,20,0.2);
}
#content div.show{display: block;}
#list li:hover{
background: rgba(100,50,20,0.4);
}
.active{background: rgba(100,50,20,0.2);}
</style>
</head>
<body>
<div id="tab">
<ul id="list">
<li class="active">第一部分</li>
<li>第二部分</li>
<li>第三部分</li>
</ul>
<div id="content">
<div class="show">JS进阶......</div>
<div>JQ精讲......</div>
<div>JS+JQ+CSS3特效、技巧、案例专题......</div>
</div>
</div>
<script>
// var list=document.getElementById('list')
// var content=document.getElementById('content')
// var oli=list.getElementsByTagName('li')
// var li_content= content.getElementsByTagName('div')
var oli=document.getElementById('list').getElementsByTagName('li')
var li_content= document.getElementById('content').getElementsByTagName('div')
for(var i=0;i<oli.length;i++){
oli[i].index=i
oli[i].onclick=function(){ //首先获取到当前被点击li的索引
//alert(this.index) //点击后让相应的div显示到当前
for(var j=0;j<li_content.length;j++){
oli[j].className="";
li_content[j].style.display='none'
}
li_content[this.index].style.display='block';
oli[this.index].className="active"; }
}
</script>
</body>
</html>