本文實例為大家分享了js實現(xiàn)選項卡效果的具體代碼,供大家參考,具體內(nèi)容如下
成都創(chuàng)新互聯(lián)是一家專注于做網(wǎng)站、網(wǎng)站設(shè)計與策劃設(shè)計,博白網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十余年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:博白等地區(qū)。博白做網(wǎng)站價格咨詢:18982081108
<!DOCTYPE html> <html> <head> <title></title> </head> <script type="text/javascript"> window.onload=function(){ var ob = document.getElementById('div1'); var ob1 = div1.getElementsByTagName('input'); var ob2= div1.getElementsByTagName('div'); for(var i = 0;i< ob1.length;i++){ ob1[i].index=i; ob1[i].onmouseover=function(){ for(var i = 0;i< ob1.length;i++){ ob2[i].style.display='none'; ob1[i].className=''; } this.className='active'; ob2[this.index].style.display='block'; } ob1[i].onmouseout=function(){ for(var i=0 ; i< ob1.length;i++){ ob2[i]['style']['display']='none'; } } } }; </script> <body> <style type="text/css"> #div1 div{ width: 100px; height: 100px; border-top: 2px solid grey; background-color: #ccc; } .active { background-color: yellow; } </style> <div id="div1"> <input type="button" value="1" class="active"> <input type="button" value="2"> <input type="button" value="3"> <input type="button" value="4"> <div >1111</div> <div >2222</div> <div >3333</div> <div >4444</div> </div> </body> </html>
如果大家還想深入學(xué)習(xí),可以點擊兩個精彩的專題:javascript選項卡操作方法匯總 jquery選項卡操作方法匯總
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。
新聞名稱:js實現(xiàn)選項卡效果
鏈接URL:http://www.chinadenli.net/article12/gjscgc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、App設(shè)計、商城網(wǎng)站、網(wǎng)站營銷、移動網(wǎng)站建設(shè)、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)