jquery URL参数判断,确定菜单样式


复制代码 代码如下:

$(function() {
var Param = window.location.href.split('?')[1];
var Uid;
var aq = Param.indexOf('&');
if (aq < 0) {
Uid = Param.substring(4);
} else {
var Psd = Param.split('&')[0];
Uid = Psd.substring(4);
}
var _NaN = /^\d{1,5}$/;
if (!_NaN.exec(Uid)) {
alert("参数错误!");
history.go( - 1);
};
$(".L_l_list_rp li").addClass("l_m_out");
$(".L_l_list_rp li").find("a").each(function(e) {
var lid = $(this).attr("href").substring(5);
if (lid == Uid) {
$(".L_l_list_rp li:eq(" + e + ")").removeClass("l_m_out").addClass("l_m_on")
}
});
$(".L_l_list_rp li").each(function() {
if ($(this).hasClass("l_m_out")) {
$(this).hover(function() {
$(this).removeClass("l_m_out").addClass("l_m_on")
},
function() {
$(this).removeClass("l_m_on").addClass("l_m_out")
})
}
});
$(".L_l_list_rp li").click(function() {
var href = $(this).find("a").attr("href");
location.href = href;
})
})

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3