想要实现点击右下角数字显示相应图片,请问哪里有问题
*{margin: 0;padding: 0;}a{text-decoration: none;}ul{list-style: none;}.box{position: relative;border: 1px solid blue;width: 500px;height: 300px;}.box .lef{position: absolute;top: 0;left: 0;width: 20px;height: 100px;border: 1px solid blue;}.box .lef>li{width: 20px;height: 20px;text-align: center;line-height: 20px;background: #000;color: #fff;margin-bottom: 5px;}.box .rig{position: absolute;top: 0;left: 20px;width: 480px;height: 300px;border: 1px solid red;}.box .rig .list .img li{display: none;position: absolute;top: 0;left: 0;}.box .rig .list .img li.open{display: block;}.box .rig .tab{position: absolute;bottom: 0;right: 0;width: 100px;height: 20px;border: 1px solid red;}.box .rig .tab li{width: 20px;height: 20px;margin-right: 5px;text-align: center;line-height: 20px;background: #000;color: #fff;float: left;cursor: pointer;}
</ul>
<script>var oTab = document.getElementsByClassName('tab')[0].getElementsByTagName('li'),oImg = document.getElementsByClassName("img")[0].getElementsByTagName("li"),length = oTab.length;for(var i=0; i |
免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。
版权声明:作者保留权利,不代表天盟立场。
|
|
|
|
你可以找一些關於“JS中for循环变量作用域”的資料看一下 |
|
|
|
|
而且你也不用寫那麼多個
</ul>
1
2
3
4
</ul>
寫一個就可以了,然後當點擊數字顯示相應圖片,其他圖片消失就行 |
|
|
|
|
<script>
var oTab = document.getElementsByClassName('tab')[0].getElementsByTagName('li'),
oImg = document.getElementsByClassName("img")[0].getElementsByTagName("li"),
length = oTab.length;
for(var i=0; i |
|
|
|
|