Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove <li> elements that does not contain a certain "href" value inside <a>

I have bought a wordpress theme called Salient : http://themenectar.com/demo/salient-frostwave/home-basic/

It has this AJAX search (little search icon in the menu) and I want to remove any search results from the list that has a certain href value, say "portfolio" in it.

I have tried with adding following code as a "raw html element" inside script tags in the page builder plugin but it did not work

$('a[href*="portfolio"]').css.({display:"none"})

How to I implement this on wordpress?

Update :

Thanks for all the answers. There was a "." after "css" and the correct line should be :

$('a[href*="portfolio"]').css({display:"none"})

Now I need to know how to select and hide all other elements that does not contain "portfolio". i.e. the end result will only have the items with "portfolio" in it.

I tried

href!="portfolio"

But it does not select any because != matches the exact and only "portfolio" where as my "portfolio can be anywhere in the link.

like image 207
MaxE Avatar asked Aug 18 '26 19:08

MaxE


1 Answers

To hide all elements that does NOT contain the word portfolio:

$('a:not([href*="portfolio"])').css({display:"none"});
like image 58
Daniel C Avatar answered Aug 21 '26 08:08

Daniel C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!