views:

22

answers:

1

a have an asp repeater that is repeating a links on a page with different urls. I want to hide any links (using jquery) that contain the word 'text' in their href. How can i do this?

if($(".fsproductsStcokistButton:contains('text')"))
{
    $(this).css("display", "none");
}
+1  A: 

You can just chain it, like this:

$(".fsproductsStcokistButton:contains('text')").hide();

.hide() is a shortcut for the display: none;, and the selector itself will only return the elements that contain that text, so you're all set. For an attribute check, like href, use an attribute-contains selector, like this:

$(".fsproductsStcokistButton[href*='text']").hide();
Nick Craver
ive tried this but its not making the link disappear. i was wondering if contains would work because ive only used it for elements that encapsulate text like divs or labels whereas with a link i want to look at the href parameter.
phil crowe
@phil - In that case you need something like `".fsproductsStcokistButton[href*='text']"`.
Nick Craver
thats nick. didnt realise you could call on parameters that way!
phil crowe