$("tr").each(function() { $("TD", $(this)).get(0).addClass("tomas") });
On Jun 8, 6:40 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote: > > $('tr > td').addClass("tomas"); > > actually, that will select all <td> elements that are children of a > <tr> element -- in other words, all <td> elements. > > Try this instead: > > $('td:first-child').addClass('tomas'); > > That selects all <td> elements that are the first child of their > parent element. > > This works equally well: > > $('td:nth-child(1)').addClass('tomas'); > > * Note: :nth-child(n) is the only "1-based" jQuery selector, since it > is solely based on the CSS pseudo-class, which is also 1-based. > > --Karl > _________________ > Karl Swedbergwww.englishrules.comwww.learningjquery.com > > On Jun 8, 2007, at 12:28 PM, Alexandre Plennevaux wrote: > > > > > > > $('tr > td').addClass("tomas"); > > > -----Original Message----- > > From: jquery-en@googlegroups.com [mailto:jquery- > > [EMAIL PROTECTED] On > > Behalf Of jorgeBadaBing > > Sent: vendredi 8 juin 2007 16:14 > > To: jQuery (English) > > Subject: [jQuery] Selecting the first TD of every Row > > > I have been looking online at the documentation and don't seen to > > have any > > luck find a way of doing this. > > > So far I can do this: > > > $("td:first").addClass("tomas"); > > > Which applies a class to the first td it founds in the table. > > > How can I select the first td for every tr? > > > Help will be much appreciated. > > > Thanks! > > > Ce message Envoi est certifié sans virus connu. > > Analyse effectuée par AVG. > > Version: 7.5.472 / Base de données virus: 269.8.11/838 - Date: > > 7/06/2007 > > 14:21- Hide quoted text - > > - Show quoted text -