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

簡單實(shí)現(xiàn)js選項(xiàng)卡切換效果

 更新時(shí)間:2017年02月09日 17:02:12   作者:Lland  
這篇文章主要為大家詳細(xì)介紹了簡單實(shí)現(xiàn)js選項(xiàng)卡切換效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了js選項(xiàng)卡切換效果的具體代碼,供大家參考,具體內(nèi)容如下

實(shí)現(xiàn)思路:

1、首先獲取id元素。
2、for循環(huán)歷遍按鈕元素添加onclick事件。
3、排他思想,點(diǎn)擊按鈕時(shí)設(shè)置所有選項(xiàng)卡按鈕樣式為空,利用this關(guān)鍵字指定當(dāng)前選項(xiàng)卡獲得高亮樣式。
4、下面的多個(gè)div內(nèi)容塊以此類推。

源代碼:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>簡單的選項(xiàng)卡切換(仿Hao123導(dǎo)航)</title>
</head>
<style>
 * {
  margin: 0;
  padding: 0;
 }
 .box {
  width: 278px;
  margin: 0 auto;
  margin-top: 100px;
  background-color: #F7F7F8;
  overflow: hidden;
 }
 .btn button {
  outline:none;
  color: #616161;
  font:14px/100% arial,"Hiragino Sans GB","Hiragino Sans GB W3",\5b8b\4f53;
  border: none;
  height: 34px;
  width: 51px;
  background-color: #F7F7F8;
  float: left;
  cursor: pointer;
 }
 .box .btn i {
  height: 16px;
  border-left: 1px solid #EAEAEA;
  margin-top: 9px;
  float: left;
  _font-size: 0px;
 }
 .box .btn button:hover {
  color: #0AA770;
 }
 .box .btn s {
  cursor: pointer;
  text-decoration: none;
  font:14px/34px arial,"Hiragino Sans GB","Hiragino Sans GB W3",\5b8b\4f53;
 }
 #box1 #btns .clickbtn {
  border-top: 1px solid #0AA770;
  color: #0AA770;
 }
 .bottom {
  display: none;
  position: absolute;
  width: 278px;
  height: 110px;
  color: #fff;
  text-align: center;
  font:14px/100% arial,"Hiragino Sans GB","Hiragino Sans GB W3",\5b8b\4f53;
 }
 .bottom a {
  color: #fff;
  position: relative;
  top: -20px;
  left: 0px;
  text-decoration: none;
 }
 .bottom a:hover {
  text-decoration: underline;
 }
</style>
<script>
 window.onload = function(){
  var btns = document.getElementById("btns").getElementsByTagName("button");
  var divs = document.getElementById("bottomdivs").getElementsByTagName("div");
  btns[0].className = "clickbtn";
   for(var i = 0;i<btns.length;i++){
    btns[i].index = i;
    btns[i].onclick = function(){
     //alert(this.index);
     for(var j = 0;j<btns.length;j++){
      btns[j].className = "";
     }
     this.className = "clickbtn";
     for(var b = 0;b<btns.length;b++){
      divs[b].style.display = "none";
     }
     divs[this.index].style.display = "block";

    }
  }
 }
</script>
<body>
<div class="box" id="box1">
 <div class="btn" id="btns">
  <button>推介</button>
  <i></i>
  <button>社會(huì)</button>
  <i></i>
  <button>娛樂</button>
  <i></i>
  <button>軍事</button>
  <i></i>
  <button>體育</button>
  <s>+</s>
 </div>
 <div id="bottomdivs">
  <div class="bottom" style="display: block">
   <img src="images/01.jpg" alt="">
   <h4><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >小伙直播時(shí)遭遇“鬧鬼”事件 全過程被拍下</a></h4>
  </div>
  <div class="bottom">
   <img src="images/02.jpg" alt="">
   <h4><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >男子穿新郎裝背充氣娃娃游街</a></h4>
  </div>
  <div class="bottom">
   <img src="images/03.jpg" alt="">
   <h4><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >她滿足所有人對(duì)才女的幻想</a></h4>
  </div>
  <div class="bottom">
   <img src="images/04.jpg" alt="">
   <h4><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >王毅回應(yīng)中美是否會(huì)在南海發(fā)生沖突</a></h4>
  </div>
  <div class="bottom">
   <img src="images/05.jpg" alt="">
   <h4><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >劉翔與嬌妻秀恩愛 豪車曝光車牌太搶眼</a></h4>
  </div>
 </div>
</div>
</body>
</html>

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Bootstrap的Carousel配合dropload.js實(shí)現(xiàn)移動(dòng)端滑動(dòng)切換圖片

    Bootstrap的Carousel配合dropload.js實(shí)現(xiàn)移動(dòng)端滑動(dòng)切換圖片

    這篇文章主要介紹了bootstrap的Carousel配合dropload.js實(shí)現(xiàn)移動(dòng)端滑動(dòng)切換圖片,實(shí)現(xiàn)方法非常簡單,具有參考借鑒價(jià)值,需要的朋友可以參考下
    2017-03-03
  • js實(shí)現(xiàn)tab欄切換制作

    js實(shí)現(xiàn)tab欄切換制作

    這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)tab欄切換制作,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • javascript判斷chrome瀏覽器的方法

    javascript判斷chrome瀏覽器的方法

    這篇文章主要介紹了javascript判斷chrome瀏覽器的方法,通過userAgent判斷檢測(cè)一下userAgent返回的字符串里面是否包含“Chrome”,需要的朋友可以參考下
    2014-03-03
  • javascript獲取表格 td 中的內(nèi)容

    javascript獲取表格 td 中的內(nèi)容

    可以獲取html table中的td中的內(nèi)容。非常的不錯(cuò)。
    2009-07-07
  • 淺析TypeScript 命名空間

    淺析TypeScript 命名空間

    命名空間一個(gè)最明確的目的就是解決重名問題。這篇文章主要介紹了TypeScript 命名空間的相關(guān)知識(shí),本文通過實(shí)例詳解給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2020-03-03
  • uni-app動(dòng)態(tài)修改主題色的方法詳解

    uni-app動(dòng)態(tài)修改主題色的方法詳解

    最近在看uniapp開發(fā)app時(shí)需要實(shí)現(xiàn)動(dòng)態(tài)修改主題色的功能,這篇文章主要給大家介紹了關(guān)于uni-app動(dòng)態(tài)修改主題色的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-12-12
  • JSChart輕量級(jí)圖形報(bào)表工具(內(nèi)置函數(shù)中文參考)

    JSChart輕量級(jí)圖形報(bào)表工具(內(nèi)置函數(shù)中文參考)

    JSChart是一個(gè)輕量級(jí)的在線圖表生成工具,本身十分小巧,簡單易用,相對(duì)來講功能也不是特別強(qiáng)大,但是對(duì)于一些要求不高的應(yīng)用來講已經(jīng)夠用了,最近兩天在做一個(gè)監(jiān)控系統(tǒng),想到了它。
    2010-10-10
  • 使用非html5實(shí)現(xiàn)js板連連看游戲示例代碼

    使用非html5實(shí)現(xiàn)js板連連看游戲示例代碼

    連連看游戲通常情況下都是使用html5來實(shí)現(xiàn)的,不過從現(xiàn)在開始就可以使用js來實(shí)現(xiàn)了,具體的代碼如下,喜歡的朋友可以參考下,希望對(duì)大家有所幫助
    2013-09-09
  • 自己做的模擬模態(tài)對(duì)話框?qū)崿F(xiàn)代碼

    自己做的模擬模態(tài)對(duì)話框?qū)崿F(xiàn)代碼

    最近做完一個(gè)項(xiàng)目,發(fā)現(xiàn)瀏覽器兼容問題,模態(tài)對(duì)話框只有IE支持,但是IE9又不能支持帶框架的對(duì)話框,那個(gè)對(duì)話框的大小打死都設(shè)置不了,在網(wǎng)上查說因?yàn)楹枚喙δ鼙籌E9屏蔽了,于是自己做了一個(gè)模擬對(duì)話框的東西
    2012-05-05
  • JavaScript邏輯運(yùn)算符相關(guān)總結(jié)

    JavaScript邏輯運(yùn)算符相關(guān)總結(jié)

    這篇文章主要介紹了JavaScript邏輯運(yùn)算符的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)JavaScript,感興趣的朋友可以了解下
    2020-09-09

最新評(píng)論