Reputation: 2674
jQuery(".rfr-col-title").css("display", "none");
I would like to hide this class .rfr-col-title if the url contains abc/Lists/abc/DispForm.aspx?ID=
http://win-e98sopqc735/abc/Lists/abc/DispForm.aspx?ID=
Upvotes: 2
Views: 7739
Reputation: 121
How about this
var url = window.location.pathname;
if ("url:contains('abc/Lists/abc/DispForm.aspx?ID=')"){
$(".rfr-col-title").hide();
}
Upvotes: 0
Reputation: 30099
The jQuery way would be to do an attribute selector:
$('a[href*="abc/Lists/abc/DispForm.aspx?ID="]').hide();
The *=
means "contains".
You could also use ^=
for "begins with" or $=
for "ends with".
Example: http://jsfiddle.net/dQFJe/
Attribute selector docs: http://api.jquery.com/category/selectors/attribute-selectors/
Edit
I just reread the question. Are you talking about the url of the page? If so, you have to do an if
statement on a window location match:
if(window.location.href.match("abc/Lists/abc/DispForm.aspx?ID=")) {
$(".rfr-col-title").hide();
}
Example: http://jsfiddle.net/EyVr4/
Upvotes: 3
Reputation: 65785
jQuery do have a attribute contain selector. So you can do this:
$('a[href*="abc/Lists/abc/DispForm.aspx?ID="]').hide();
Instead of .css('display', 'none')
use .hide()
Upvotes: 0
Reputation: 17666
if(window.location.href.indexOf("abc/Lists/abc/DispForm.aspx?ID=") > -1) {
jQuery(".rfr-col-title").hide();
}
Upvotes: 1