Remove links that have a certain string with Jquery

1

Good evening, good people ...

Good my doubt and the following, I have a list of links ...

<ul>
<li><a href="baixar.php?musica=teste-ativo.mp3">Musica 1</a></li>
<li><a href="baixar.php?musica=teste-desativado.mp3">Musica 2</a></li>
<li><a href="baixar.php?musica=teste-ativo.mp3">Musica 3</a><li>
<li><a href="baixar.php?musica=teste-desativado.mp3">Musica 3</a></li>
</ul>

Well, now I just wanted the links that have the string "deactivated" in the url to be hidden, with hide (); for example

Att ... Thanks

    
asked by anonymous 09.05.2015 / 01:08

1 answer

2

You can use the "attribute contains selector" of jQuery to select the links that contain the string " disabled ":

$("li > a[href*='desativado']").hide();

Note that this will hide the text, but the list item keeps popping up. What you probably want to do is remove the elements from the list, which you can do using remove() ( example in JSFiddle ):

$("li > a[href*='desativado']").parent().remove();
    
09.05.2015 / 02:21