<!DOCTYPE html><html><head>? ? <meta charset="UTF-8">? ? <title>實(shí)踐題 - 選項(xiàng)卡</title>? ? <style type="text/css">? ? ?/* CSS樣式制作 */ ?? ? *{list-style:none;}? ? a{color:black;text-decoration:none;outline:none;}? ? li{float:left;text-align:center;margin-right:10px;line-height:30px;background:white;}? ? .clear{clear:both;}? ? .list{width:60px;border:3px solid red;}? ? #main div{border:1px solid blue;line-height:2;}? ? #main{width:500px;height:700px;}? ? .list:hover{cursor:pointer;}? ? .blo{display:block;}? ? .hide{display:none;}? ? </style>? ? <script type="text/javascript">? ? ? ?window.onload=function(){? ? ? ?var list=document.getElementsByName('content');? ? ? ?//document.write(list.length);? ? ? ?var li=document.getElementsByClassName('list');? ? ? ?//document.write(li.length);? ? ? ?//for(var i=0;i<3;i++)? ? ? // {? ? ? ? ? ?li[0].onclick=function() {? ? ? ? ? ? ? ?list[0].className='blo';? ? ? ? ? ? ? ?list[(0+1)%3].className='hide';? ? ? ? ? ? ? ?list[(0+2)%3].className='hide';? ? ? ? ? ?}? ? ? ? ? ?li[1].onclick=function() {? ? ? ? ? ? ? ?list[1].className='blo';? ? ? ? ? ? ? ?list[(1+1)%3].className='hide';? ? ? ? ? ? ? ?list[(1+2)%3].className='hide';? ? ? ? ? ?}? ? ? ? ? ?li[2].onclick=function() {? ? ? ? ? ? ? ?list[2].className='blo';? ? ? ? ? ? ? ?list[(2+1)%3].className='hide';? ? ? ? ? ? ? ?list[(2+2)%3].className='hide';? ? ? ? ? ?}? ? ? ?//}? ? ? ?? ? ? ?? ? ?}? ? ? ?? ? // JS實(shí)現(xiàn)選項(xiàng)卡切換? ??? ??? ? </script>?</head><body><!-- HTML頁(yè)面布局 --><ul><li><a href="#"><div>房產(chǎn)</div></a></li><li><a href="#"><div>家居</div></a></li><li><a href="#"><div>二手房</div></a></li></ul><div></div><div id="main"><div name="content">? ? 275萬(wàn)購(gòu)昌平鄰鐵三居 總價(jià)20萬(wàn)買一居</br>? ? 200萬(wàn)內(nèi)購(gòu)五環(huán)三居 140萬(wàn)安家東三環(huán)</br>? ? 北京首現(xiàn)零首付樓盤 53萬(wàn)購(gòu)東5環(huán)50平</br>? ? 京樓盤直降5000 中信府 公園樓王現(xiàn)房?</div><div name="content">? ? ?40平出租屋大改造 美少女的混搭小窩</br>? ? ?經(jīng)典清新簡(jiǎn)歐愛(ài)家 90平老房煥發(fā)新生</br>? ? ?新中式的酷色溫情 66平撞色活潑家居</br>? ? ?瓷磚就像選好老婆 衛(wèi)生間煙道的設(shè)計(jì) ?</div><div name="content">? ? 通州豪華3居260萬(wàn) 二環(huán)稀缺2居250w甩</br>? ? ?西3環(huán)通透2居290萬(wàn) 130萬(wàn)2居限量搶購(gòu)</br>? ? ?黃城根小學(xué)學(xué)區(qū)僅260萬(wàn) 121平70萬(wàn)拋!</br>? ? ?獨(dú)家別墅280萬(wàn) 蘇州橋2居優(yōu)惠價(jià)248萬(wàn)?</div></div>?</body></html>
為什么js的最后部分換成for循環(huán)就不行了,分開(kāi)寫又可以
BlueWeekend
2016-02-28 17:01:45