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=
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=
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/
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()
How about this
var url = window.location.pathname;
if ("url:contains('abc/Lists/abc/DispForm.aspx?ID=')"){
$(".rfr-col-title").hide();
}
if condition has some issues. 1) It will always evaluate to true because it is a string literal, and therefore "truthy". 2) JavaScript doesn't have a contains method. 3) Even if JavaScript did have a contains method, you can't invoke it with a :. 4) If you were trying to use jQuery's contains pseudo-selector, it would need to be used in a selector context (e.g., $('.foo:contains(...)')), not to mention that :contains is only used for searching the tag body, not the href attribute.