js實現(xiàn)選項卡效果
本文實例為大家分享了js實現(xiàn)選項卡效果的具體代碼,供大家參考,具體內(nèi)容如下
<!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 style='display: none;'>2222</div><div style='display: none;'>3333</div><div style='display: none;'>4444</div></div></body></html>
如果大家還想深入學(xué)習,可以點擊兩個精彩的專題:javascript選項卡操作方法匯總 jquery選項卡操作方法匯總
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 基于javaweb+jsp實現(xiàn)學(xué)生宿舍管理系統(tǒng)2. 多級聯(lián)動下拉選擇框,動態(tài)獲取下一級3. ASP.NET MVC實現(xiàn)樹形導(dǎo)航菜單4. 如何封裝一個Ajax函數(shù)5. 聊聊python dropna()和notnull()的用法區(qū)別6. Laravel Eloquent ORM高級部分解析7. Spring security 自定義過濾器實現(xiàn)Json參數(shù)傳遞并兼容表單參數(shù)(實例代碼)8. jsp response.sendRedirect()用法詳解9. PHP擴展之URL編碼、解碼及解析——URLs10. Java 接口和抽象類的區(qū)別詳解
