javascript切换div

 js代码:

   function selectTag(showContent, selfObj) {
           // 操作标签
           var tag = document.getElementById("tags").getElementsByTagName("li");
           var taglength = tag.length;
           for (i = 0; i < taglength; i++) {
               tag[i].className = "";
           }
           selfObj.parentNode.className = "selectTag";
           // 操作内容
           for (i = 0; j = document.getElementById("tagContent" + i); i++) {
               j.style.display = "none";
           }
           document.getElementById(showContent).style.display = "block";
       }

 

页面代码:

<div id=tagContent>
                <div class="tagContent selectTag" id=tagContent0>
                 <ul class="sider_luckyroom_items clear">
                     <li class="sider_luckyroom_pic"><a href="#" title="北京亮马河酒店式公寓" target="_blank">
                   <img src="upload/room1.jpg"   alt="北京亮马河酒店式公寓"/></a></li>
                        <li class="sider_luckyroom_name"> <a href="#" title="北京亮马河酒店式公寓" target="_blank">北京亮马河酒店式公寓</a></li>
                        <li class="star_levels"></li>
                        <li>出价次数:&nbsp;<span>30次</span> </li>
                       
                    </ul>
                  
                    <ul class="sider_luckyroom_items  clear">
                     <li class="sider_luckyroom_pic"><a href="#" title="北京亮马河酒店式公寓" target="_blank">
                   <img src="upload/room1.jpg"   alt="北京亮马河酒店式公寓"/></a></li>
                        <li class="sider_luckyroom_name"> <a href="#" title="北京亮马河酒店式公寓" target="_blank">北京亮马河酒店式公寓</a></li>
                        <li class="star_levels"></li>
                        <li>出价次数:&nbsp;<span>30次</span> </li>
                       
                    </ul>
                    <ul class="sider_luckyroom_items  clear">
                     <li class="sider_luckyroom_pic"><a href="#" title="北京亮马河酒店式公寓" target="_blank">
                   <img src="upload/room1.jpg"   alt="北京亮马河酒店式公寓"/></a></li>
                        <li class="sider_luckyroom_name"> <a href="#" title="北京亮马河酒店式公寓" target="_blank">北京亮马河酒店式公寓</a></li>
                        <li class="star_levels"></li>
                        <li>出价次数:&nbsp;<span>30次</span> </li>
                       
                    </ul>
                    <ul class="sider_luckyroom_items  clear">
                     <li class="sider_luckyroom_pic"><a href="#" title="北京亮马河酒店式公寓" target="_blank">
                   <img src="upload/room1.jpg"   alt="北京亮马河酒店式公寓"/></a></li>
                        <li class="sider_luckyroom_name"> <a href="#" title="北京亮马河酒店式公寓" target="_blank">北京亮马河酒店式公寓</a></li>
                        <li class="star_levels"></li>
                        <li>出价次数:&nbsp;<span>30次</span> </li>
                       
                    </ul>
                </div>
                <div class=tagContent id=tagContent1>第二个标签的内容</div>
                <div class=tagContent id=tagContent2>第三个标签的内容</div>
                 <div class=tagContent id=tagContent3>第4个标签的内容</div>
                  <div class=tagContent id=tagContent4>第5个标签的内容</div>
                  <div class=tagContent id=tagContent5>第6个标签的内容</div>
          </div>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值