Re: [jQuery] adding a class to positive and negative data cells in a table column

2007-02-19 Thread Alex Cook
Heck, I even learned something here :) I love this list... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Danny Wachsstock Sent: Saturday, February 17, 2007 8:17 PM To: discuss@jquery.com Subject: Re: [jQuery] adding a class to positive and negative data

Re: [jQuery] adding a class to positive and negative data cells in a table column

2007-02-17 Thread rolfsf
Thanks for the lesson Danny! I'd love to be a cool kid :-) I haven't had the time to fully grok what either you or Kristinn showed me, but it opened a door to understanding and I definitely appreciate that. r. Danny Wachsstock wrote: > > To select specific elements, the cool kids all use cust

Re: [jQuery] adding a class to positive and negative data cells in a table column

2007-02-17 Thread Danny Wachsstock
One thing to remember is that selectors are applied in order. $('td:nth(3):positive') gives you the positive numbers that are in the fourth cell, $('td:positive:nth(3)') gives you the fourth positive cell, probably not what you want Danny Wachsstock wrote: > > To select specific elements, the co

Re: [jQuery] adding a class to positive and negative data cells in a table column

2007-02-17 Thread Danny Wachsstock
To select specific elements, the cool kids all use custom selectors (not very well documented, but see http://docs.jquery.com/Plugins/Authoring#Using_jQuery.extend_to_extend_jQuery_itself and http://www.softwareunity.com/sandbox/JQueryMoreSelectors/ ) Basically, extend jQuery.expr[':'] with a str

Re: [jQuery] adding a class to positive and negative data cells in a table column

2007-02-16 Thread rolfsf
I posted a http://www.monkeypuzzle.net/testfiles/jquery/data_hilite/index.html working test page - thanks Kristinn!! Kristinn Sigmundsson wrote: > > Arg, stupid tabs not working here it comes again... > > $("table td").each( function () { > var nr = parseFloat($(this).text()); >

Re: [jQuery] adding a class to positive and negative data cells in a table column

2007-02-16 Thread rolfsf
thanks Kristinn! So, if I only want to do this on the 4th column of a table, would I do something like: $("table td:nth-child(3)").each( function () { var nr = parseFloat($(this).text()); if (nr >= 1.5) $(this).addClass("positive"); else if (nr <= -1.5) $(this).addClass

Re: [jQuery] adding a class to positive and negative data cells in a table column

2007-02-16 Thread Kristinn Sigmundsson
Arg, stupid tabs not working here it comes again... $("table td").each( function () { var nr = parseFloat($(this).text()); if (nr >= 1.5) $(this).addClass("positive"); else if (nr <= -1.5) $(this).addClass("negative"); }); something similar to this should work... /

Re: [jQuery] adding a class to positive and negative data cells in a table column

2007-02-16 Thread Kristinn Sigmundsson
First thought: $("table td").each( function () { var nr = parseFloat($(this).text()); if (nr > 1.5) }); On 2/16/07, rolfsf <[EMAIL PROTECTED]> wrote: > > Is there a clever way in jQuery to find non-zero data in specific columns of > a table, and assign them a class based on whether they a

[jQuery] adding a class to positive and negative data cells in a table column

2007-02-16 Thread rolfsf
Is there a clever way in jQuery to find non-zero data in specific columns of a table, and assign them a class based on whether they are positive or negative? In plain English, I want to make positive numbers green (or the cell bg) and the negative numbers red, but only in certain columns. Ideally,