I'd use a filter function. Something like this maybe:

$('#MyTable tr').filter(function() {
  return /^(Row(?!Header)|Line(?!Empty))/.test(this.id);
})

It's a kind of crazy regular expression, with negative lookaheads, but it works (as of JavaScript 1.5).

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Sep 21, 2009, at 10:32 AM, Erich Nascimento wrote:


Thank you MorningZ,

I seem to have managed to solve the problem, but I'd like to know
whether in Attribute Filters I could use more tha once the same
operator.
For exemple: to have two or more times the operator ^= to select
certain elements that iniciate with different IDs.

Perhaps that is possible and I'm not doing the right way.

Example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
   <title></title>
   <meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
   <script type="text/javascript" src="js/jquery/jquery.js"></script>

   <script type="text/javascript">
       $(document).ready(function(){
           var ElementsArray = $("#MyTable tr[id^='Row'][id^='Line']
[id!='LineEmpty'][id!='RowHeader']");

           ElementsArray.each(function(i){
               alert($(this).text());
           })
       });


   </script>

 </head>
 <body>
     <table id="MyTable">
         <tr id="RowHeader">
             <td>Col1</td>
             <td>Col2</td>
         </tr>
         <tr id="Row1">
             <td>A1</td>
             <td>B1</td>
         </tr>
         <tr id="Row2">
             <td>A2</td>
             <td>B2</td>
         </tr>
         <tr id="Line3">
             <td>A3</td>
             <td>B3</td>
         </tr>
         <tr id="Line4">
             <td>A4</td>
             <td>B4</td>
         </tr>
         <tr id="LineEmpty">
             <td>xx</td>
             <td>yy</td>
         </tr>
     </table>
 </body>
</html>

--
Thank you.

Reply via email to