JavaScript實(shí)現(xiàn)橫版菜單欄
本文實(shí)例為大家分享了JavaScript實(shí)現(xiàn)橫版菜單欄的具體代碼,供大家參考,具體內(nèi)容如下
示例代碼:
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>橫版菜單欄</title> <style> .active{ background-color: aqua; } .hide{ display: none; } .menu{ background-color: #667dbd; width: 300px; height: 30px; } .menu-item{ border: #bd342d solid 2px; cursor: pointer; /*鼠標(biāo)懸停在相應(yīng)標(biāo)簽上時(shí)變成手指的樣子*/ } .con-item{ min-height: 200px; border: solid 1px; width: 300px; } </style></head><body><!--什么時(shí)候用漂浮什么時(shí)候用內(nèi)聯(lián)標(biāo)簽?zāi)兀?-> <div class='menu'> <span m='1'>菜單一</span> <span m='2'>菜單二</span> <span m='3'>菜單三</span> </div> <div class='content'> <div c='1'>內(nèi)容一</div> <div c='2'>內(nèi)容二</div> <div c='3'>內(nèi)容三</div> </div> <script src='http://m.lshqa.cn/bcjs/jquery-1.12.4.js'></script> <script> $(’.menu-item’).click(function () { $(this).addClass(’active’).siblings().removeClass(’active’); var match = $(this).attr(’m’); $(’.content’).children(’[c=’+match+’]’).removeClass(’hide’).siblings().addClass(’hide’);// children函數(shù)的參數(shù)要求是字符串!// $(’.content’).children().eq($(this).index()).removeClass(’hide’).siblings().addClass(’hide’);// 也可以用索引的方式(.eq($(this).index()))找到對(duì)應(yīng)的標(biāo)簽,這種處理方式就不需要要用到自設(shè)屬性m和c了 }); </script></body></html>
更多菜單效果點(diǎn)擊《JavaScript菜單專題》學(xué)習(xí),還有一些不錯(cuò)的專題分享給大家: Javascript級(jí)聯(lián)菜單特效匯總
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 解決vue頁(yè)面刷新,數(shù)據(jù)丟失的問(wèn)題2. python 讀txt文件,按‘,’分割每行數(shù)據(jù)操作3. python logging.info在終端沒(méi)輸出的解決4. vue路由分文件拆分管理詳解5. vue+vuex+axios從后臺(tái)獲取數(shù)據(jù)存入vuex,組件之間共享數(shù)據(jù)操作6. Python 忽略文件名編碼的方法7. SpringBoot使用Captcha生成驗(yàn)證碼8. android studio實(shí)現(xiàn)簡(jiǎn)單的計(jì)算器(無(wú)bug)9. android 控件同時(shí)監(jiān)聽(tīng)單擊和雙擊實(shí)例10. 詳解android adb常見(jiàn)用法
