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>出价次数: <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>出价次数: <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>出价次数: <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>出价次数: <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>