首页 > 开发 > Javascript > 正文

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

2020-02-28 04:12:38
字体:
来源:转载
供稿:网友
代码如下:
$(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;
})
})
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表