Js更简单的切换

cshtml页面:

<div class="htside_rt2">
<div class="hmNewsBar">
<div class="nxMenuGroup">
<ul class="nxMenuZu">
<li class="current"><a href="/news/Index" class="mu_rd" id="category_0">热 点</a>
</li>
<li><a href="/news/index?categoryIds=37" class="mu_xw" id="category_37">新闻</a> </li>
<li><a href="/news/index?categoryIds=39" class="mu_hd" id="category_39">活动</a></li>
<li><a href="/news/index?categoryIds=38" class="mu_gg" id="category_38">公告</a> </li>
<div class="clear">
</div>
</ul>
<a href="http://DXZ.niu99.com/News" id="new_more" class="more" style="float: right;
margin-top: -25px; margin-right: 5px;">更多>></a>
</div>
<div class="nxNrshowGroup">
<div class="nxListGroup">
@{Html.RenderAction<PartController>(i => i.FontNews(7, 37, 38, 39));}
</div>
</div>
<div class="nxNrshowGroup" style="display: none">
<div class="nxListGroup">
@{Html.RenderAction<PartController>(i => i.FontNews(7, 37));}
</div>
</div>
<div class="nxNrshowGroup" style="display: none">
<div class="nxListGroup">
@{Html.RenderAction<PartController>(i => i.FontNews(7, 39));}
</div>
</div>
<div class="nxNrshowGroup" style="display: none">
<div class="nxListGroup">
@{Html.RenderAction<PartController>(i => i.FontNews(7, 38));}
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
tabLi.init();
})
</script>

 

Js页面:

 

// 热点、新闻和游戏攻略等切换
var tabLi = {

init: function () {

$(".nxMenuZu li").live("mouseover", function () {

if ($(this).attr("class") === 'current') return;

$(".nxMenuZu li.current").removeClass();
$(this).removeClass().addClass("current");

var i = $(this).index();

$(".nxNrshowGroup:visible").hide();
$(".nxNrshowGroup").eq(i).show();
$("#new_more").attr("href",$(this).children("a").attr("href"));
});
},
gameWarInit: function () {
$(".yxglMenuZu li").live("mouseover", function () {
if ($(this).find('a').attr("class") === 'on') return;

$(".yxglMenuZu li a.on").removeClass().addClass("off");
$(this).find('a').removeClass().addClass("on");

var i = $(this).index();

$(".gamegl_nrzu:visible").hide();
$(".gamegl_nrzu").eq(i).show();

});
}

}

posted on 2012-12-11 17:24  douqiumiao  阅读(4577)  评论(0编辑  收藏  举报