Javascript 使用jQuery添加到页面url
Javascript 使用jQuery添加到页面url,javascript,jquery,html,Javascript,Jquery,Html,$('.toggles span')。单击(函数(){ $(“.toggles span”).removeClass(“活动”); $(此).addClass(“活动”); }); $('.spanish')。单击(函数(){ $(location.attr('href')+'/es');) }; $('.english')。单击(函数(){ if(window.location.href.indexOf(“/es”)>-1){ location.href=location.href.repla
$('.toggles span')。单击(函数(){
$(“.toggles span”).removeClass(“活动”);
$(此).addClass(“活动”);
});
$('.spanish')。单击(函数(){
$(location.attr('href')+'/es');)
};
$('.english')。单击(函数(){
if(window.location.href.indexOf(“/es”)>-1){
location.href=location.href.replace(“/es”,”);
)
};
。西班牙语{
光标:指针;
}
.切换范围:激活{
文字装饰:下划线;
}
.西班牙语:悬停{
光标:指针;
文字装饰:下划线;
}
L1:悬停{
光标:指针;
文字装饰:下划线;
}
.西班牙语:现行{
文字装饰:下划线;
}
.主动{
文字装饰:下划线;
}
.英语{
光标:指针;
}
西班牙语|英语
与其更改位置,更好的方法是(在我看来)在s中加载两个页面,并使用按钮切换其可见性(不确定如何删除“英语”切换的/E)-使用Google有什么困难…$(location).attr('href'))
?为什么不location.href
?无论如何,您不能使用标准字符串操作来测试location.href
是否已以'/es'
结尾?如果有人想访问:example.com/page-1/es=>not怎么办found@CBroe对不起,老兄,我一定是把我的搜索写错了,因为我花了一个多小时查看t我已经更新了帖子。您需要在这里发布完整的代码示例,而不是JSFIDLE: