基于javascript實(shí)現(xiàn)最簡(jiǎn)單的選項(xiàng)卡切換效果
本文實(shí)例為大家分享了js選項(xiàng)卡切換效果的具體實(shí)現(xiàn)代碼,供大家參考,具體內(nèi)容如下
<!DOCTYPE html> <html> <head> <meta charset="gb2312" /> <title>朱朱制作</title> <script src="js/jquery.js" type="text/javascript"></script> <style> *{ margin: 0; padding: 0; } body{ background-color: #fff; font-family: "微軟雅黑"; font-size: 18px; width: 1000px; margin: 50px auto; color:#000000; } .wrapper{ width: 350px; } #nav ul{ border-bottom: 2px solid yellowgreen; height: 32px; } #nav li{ display: inline-block; border: 2px solid #999; border-bottom: none; margin-left: 10px; width: 65px; text-align: center; line-height: 30px; } #nav li:hover{ cursor: pointer; } #content{ display: block; border: 1px solid blue; border-top: none; text-align: center; height: 100px; line-height: 100px; } #nav li.on{ border-bottom: solid 2px #ffffff; } .hide{ display: none; } .show{ display: block; } </style> </head> <script type="text/javascript"> /*window.onload=change; //js代碼實(shí)現(xiàn) function change(){ this.nav=document.getElementById("nav"); this.li=nav.getElementsByTagName("li"); this.cont=document.getElementById("content"); this.divi=cont.getElementsByTagName("div"); for(var i=0;i<li.length;i++){ li[i].index=i; li[i].onclick=function(){ for(var i=0;i<li.length;i++){ li[i].className=""; divi[i].className="hide"; } li[this.index].className="on"; divi[this.index].className="show"; } } }*/ $(function(){ $('#nav li').each(function(){ $(this).click(function(){ $('#nav li').removeClass("on"); $(this).addClass("on"); $("#content div").removeClass(); $("#content div").eq($(this).index()).addClass("show").siblings().addClass("hide"); }) }) }) </script> <body> <div class="wrapper"> <div id="nav"> <ul> <li class="on">num1</li> <li>num2</li> <li>num3</li> <li>num4</li> </ul> </div><div id="content"> <div class="show">content1</div> <div class="hide">content2</div> <div class="hide">content3</div> <div class="hide">content4</div> </div> </div> </body> </html>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助。
- 輕松實(shí)現(xiàn)js選項(xiàng)卡切換效果
- 原生js實(shí)現(xiàn)tab選項(xiàng)卡切換
- 很棒的js Tab選項(xiàng)卡切換效果
- 很實(shí)用的js選項(xiàng)卡切換效果
- 很棒的js選項(xiàng)卡切換效果
- javascript css紅色經(jīng)典選項(xiàng)卡效果實(shí)現(xiàn)代碼
- 基于javascript實(shí)現(xiàn)tab選項(xiàng)卡切換特效調(diào)試筆記
- 簡(jiǎn)單實(shí)現(xiàn)js選項(xiàng)卡切換效果
- 分步解析JavaScript實(shí)現(xiàn)tab選項(xiàng)卡自動(dòng)切換功能
- JavaScript仿網(wǎng)易選項(xiàng)卡制作代碼
相關(guān)文章
JavaScript設(shè)置、獲取、清除單值和多值cookie的方法
cookie 是存儲(chǔ)于訪問(wèn)者的計(jì)算機(jī)中的變量。每當(dāng)同一臺(tái)計(jì)算機(jī)通過(guò)瀏覽器請(qǐng)求某個(gè)頁(yè)面時(shí),就會(huì)發(fā)送這個(gè) cookie。你可以使用 JavaScript 來(lái)創(chuàng)建和取回 cookie 的值,本文通過(guò)一段代碼給大家介紹js設(shè)置、獲取、清除單值和多值cookie的方法,需要的朋友一起學(xué)習(xí)吧2015-11-11頁(yè)面中實(shí)現(xiàn)setInterval和setTimeout效果示例詳解
這篇文章主要為大家介紹了不使用setTimeout和setInterval在頁(yè)面中實(shí)現(xiàn)setInterval和setTimeout效果示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09JS實(shí)現(xiàn)的RGB網(wǎng)頁(yè)顏色在線取色器完整實(shí)例
這篇文章主要介紹了JS實(shí)現(xiàn)的RGB網(wǎng)頁(yè)顏色在線取色器,結(jié)合完整實(shí)例形式分析了基于JS運(yùn)算及鼠標(biāo)事件響應(yīng)來(lái)操作頁(yè)面元素實(shí)現(xiàn)取色器功能的方法,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2016-12-12three.js實(shí)現(xiàn)圍繞某物體旋轉(zhuǎn)
本篇文章主要介紹了three.js實(shí)現(xiàn)圍繞某物體旋轉(zhuǎn)的示例代碼。具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧2017-01-01location.search在客戶端獲取Url參數(shù)的方法
最近一直在寫html,剛接觸到,感覺挺復(fù)雜的。。比如傳參,在.net里可以直接用Request接受,而在html中還要經(jīng)過(guò)處理,找了一些資料,寫了個(gè)方法。2010-06-06webpack打包html里面img后src為“[object Module]”問(wèn)題
這篇文章主要介紹了webpack打包html里面img后src為“[object Module]”問(wèn)題,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12JavaScript實(shí)現(xiàn)獲取用戶單擊body中所有A標(biāo)簽內(nèi)容的方法
這篇文章主要介紹了JavaScript實(shí)現(xiàn)獲取用戶單擊body中所有A標(biāo)簽內(nèi)容的方法,涉及javascript針對(duì)頁(yè)面元素及事件響應(yīng)相關(guān)操作技巧,需要的朋友可以參考下2017-06-06