2011-03-16 38 views

回答

3

在当前页面的加载:

$(function() { 
    if (location.href.match(/\_edit/)) { 
     $('div#editor').show(); 
    } 
    else { 
     $('div#editor').hide(); 
    } 
}); 

通过一个单击处理程序:

只需使用的href的字符串匹配方法来选择是否显示或隐藏股利。

$('a').click(function() { 
    var href = $(this).attr('href'); 
    if (href.match(/\/_edit/)) { 
     $('div#editor').show(); 
    } 
    else { 
     $('div#editor').hide(); 
    } 
}); 
+0

对不起,我的意思是在页面加载,当它加载。 – Jake 2011-03-16 03:05:08

+0

@Jake - 没有什么问题只是匹配'location.href'而不是文档就绪处理程序中单击锚点的href。 – tvanfosson 2011-03-16 03:11:29

+0

schwee感谢堆!生病给它一个镜头 – Jake 2011-03-16 03:13:25

相关问题