jQuery HTML Element How to - Hide anchor in li for containing certain text








Question

We would like to know how to hide anchor in li for containing certain text.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(function(){<!--from ww w.  ja v  a2 s  .c  o m-->

        $("ul li a:contains('AIRPORTS')").hide();

});
</script>
</head>
<body>
  <ul>
    <li><a class="static" href="#">ALL</a></li>
    <li><a class="static" href="#">AIRPORTS</a></li>
  </ul>
</body>
</html>

The code above is rendered as follows: