Jquery 当前页面的活动菜单类
我正在制作公文包网站模板。我的整个ajax站点的“活动链接”有问题 当我打开url时(http://bit.ly/d5qNeN)直接来说,url没有提供Jquery 当前页面的活动菜单类,jquery,ajax,hash,history,Jquery,Ajax,Hash,History,我正在制作公文包网站模板。我的整个ajax站点的“活动链接”有问题 当我打开url时(http://bit.ly/d5qNeN)直接来说,url没有提供addClass函数 如何为直接打开的URL添加“选定”类 这是我的jquery代码,它将“selected”类添加到我的导航栏中 $j("a[rel='history']").click(function(){ $j("a[rel='history']").addClass('selected').not(this).removeCl
addClass
函数
如何为直接打开的URL添加“选定”类
这是我的jquery代码,它将“selected”类添加到我的导航栏中
$j("a[rel='history']").click(function(){
$j("a[rel='history']").addClass('selected').not(this).removeClass('selected');
// Get the hash from the link that was clicked
// jQuery.history.load("new-hash-value");
var hash = $j(this).attr('href');
hash = hash.replace(/^.*#/, '');
// Load this hash with the history plugin
$j.historyLoad(hash);
$j('#load').fadeIn('normal');
if(!$j('#load').get(0)) {
$j('#content').append('<div id="load"></div>');
}
return false;
});
$j(“a[rel='history'])。单击(函数(){
$j(“a[rel='history']”).addClass('selected')。not(this).removeClass('selected');
//从单击的链接获取哈希值
//jQuery.history.load(“新哈希值”);
var hash=$j(this.attr('href');
hash=hash.replace(/^..#/,“”);
//使用历史插件加载此哈希
$j.historyLoad(哈希);
$j(“#load”).fadeIn('normal');
如果(!$j(“#加载”).get(0)){
$j(“#content”)。追加(“”);
}
返回false;
});
很抱歉,我不明白。你能告诉我确切的位置吗?因为我在everyline上尝试了你的代码,但没有成功哦,我的错:应该是location.hash,而不是href。我改变了。
$j(function() { // on DOM ready
hash = location.hash; // everything after a # in the URL
if(hash) {
// "click" on menu entry that links to expected target
$j("a[rel='history'][href="+hash+"]").trigger("click");
}
});