.has()

.has()

I am also trying to use the .has() filter to add a class to the text inside the Div tag "Test". It doesn't work. I don't seem to figure out what I am doing wrong here....


  1. <script type="text/javascript">
  2.     $(function() {  
  3.   $("div:has([id=first])").addClass("a");
  4.   
  5.     });
  6. </script>

  7. <style type="text/css">
  8. .a { color: Navy; }
  9. .b { color: Maroon; }
  10. </style>
  11. <div id="first">Test </div>