Hi Karl I can't believe you did a test case for me. That's absolutely brilliant. Thank you greatly.
It appears you are correct. I've modified your test case to more closely reflect my scenario: http://devel.wynlearn.net.au/nth-child.html It appears to be working as expected here. Of course my actual code has more default styles applied to it and there is other code in the $(document).ready() but this is a bit of a mystery. My actual code is centering the th cells but not the td cells. Firebug allows me to see that the inline style definitions jQuery is adding to the th cells are not being applied to the td cells. Strangely that can be reproduced in a vice-versa fashion as well! Rather strange. My actual code, if you are interested, is here: http://devel.wynlearn.net.au/forum.cgi though I'll be hacking away at it after writing this reply. Once again, thanks for going that extra effort more than once. Good karma to you! pd On May 8, 1:37 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote: > Hmmm. I'm not sure what could be causing the problem you're having > with classes. > > I put together a simple test page using your code:> $('.relevantTableClass > td:nth-child(2)').css('textAlign', 'center'); > > inside $(document).ready > and it works for me as expected:http://test.learningjquery.com/nth-child.html > > Let me know if that helps you pinpoint any differences in your code > that might be causing the problem. Otherwise, if you could provide a > link to your page, that might help us troubleshoot. > > --Karl > _________________ > Karl Swedbergwww.englishrules.comwww.learningjquery.com > > On May 7, 2007, at 10:15 PM, pd wrote: > > > > > Ah, one problem Karl. Thanks again for your help though there's just > > one thing that I don't really understand. > > > I was attempting to use such a selector in a site-wide $ > > (document).ready() context. Hence this applies to all tables which is > > problematic. > > > Hence initially I was attempting the equivalent (using your example) > > of: > > > $('.relevantTableClass td:nth-child(2)').css('textAlign', 'center'); > > > and I've tried this again just now but it fails. > > > Should a similar syntax be possible? > > > The following works: > > > $('#relevantTableId td:nth-child(2)').css('textAlign', 'center'); > > > however a class-based solution would work better for me. Is this > > possible? > > > Thanks > > pd > > > On May 8, 11:20 am, Karl Swedberg <[EMAIL PROTECTED]> wrote: > >> If I understand your situation correctly, you might be looking > >> for :nth-child() > > >> You could, for example, get the 2nd cell of each row this way: > >> $('td:nth-child(2)').css('textAlign', 'center'); > > >> Remember that nth-child() is the only jQuery selector that is 1- > >> based, because it's based solely on the CSS spec. > > >> Cheers, > > >> --Karl > >> _________________ > >> Karl Swedbergwww.englishrules.comwww.learningjquery.com > > >> On May 7, 2007, at 9:10 PM, pd wrote: > > >>> Hello > > >>> I've looked up > > >>>http://docs.jquery.com/Selectors > > >>> and alas I can't determine if there is a way to select the x td > >>> of all > >>> rows of a table. > > >>> The use case is that i have a table for a forum and I'd like to > >>> center > >>> text-align the 'Topics' and 'Replies' totals columns. > > >>> Thanks > >>> pd