Or rather the question should be can the :contains selector have a context for its search......and if I make the 'this' to be it will it work.....
On Dec 20, 1:43 pm, "[email protected]" <[email protected]> wrote: > Hi, > I am trying to match the content in 'td' and think the problem is with > contains when it is trying to query withing 'td'.... > > $(":contains('Comedy')",'td').css("background- > color","green"); > doesn't work... > > but if I tried... > $(":contains('Comedy')",'tr').css("background- > color","green"); > > this WORKS ....WHY....???? > > http://chinnakaruppan.googlepages.com/index.html > > Please find below the full code... > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" > "http://www.w3.org/TR/html4/loose.dtd"> > > <html xmlns="http://www.w3.org/1999/xhtml"> > <head> > <meta name="generator" content= > "HTML Tidy, seewww.w3.org" /> > <meta http-equiv="Content-Type" content= > "text/html; charset=utf-8" /> > > <title>New Web Project</title> > <style type='text/css'> > > </style> > <script type="text/javascript" src="/lib/jquery/jquery.js"> > </script> > <script type="text/javascript"> > $(document).ready(function(){ > > $('tr td').filter(function(){ > return $(':contains("History")',this); > }).css("background-color","red"); > > $("td:contains('Tragedy')").css("background-color","blue"); > $('tr td').filter(":contains('Comedy')").css("background- > color","green"); > > }) > > </script> > </head> > > <body> > <table> > <tr class="header"> > <th>Title</th> > > <th>Category</th> > </tr> > > <tr> > <td>As You Like It</td> > > <td>Comedy</td> > </tr> > > <tr> > <td>All's Well that Ends Well</td> > > <td>Comedy</td> > </tr> > > <tr> > <td>Hamlet</td> > > <td>Tragedy</td> > </tr> > > <tr> > <td>Macbeth</td> > > <td>Tragedy</td> > </tr> > > <tr> > <td>Romeo and Juliet</td> > > <td>Tragedy</td> > </tr> > > <tr> > <td>Henry IV, Part I</td> > > <td>History</td> > </tr> > > <tr> > <td>Henry V</td> > > <td>History</td> > </tr> > </table> > </body> > </html>

