Hi Kelvin, This looks really good.
It's not working but this may be down to something really stupid on my part. I've put your code into an example to give an idea of what I'm trying to do: http://donkeyontheedge.com/jqtest/ (I'm looking at this in Firefox) Could it be that $this.val() doesn't return an integer that corrresponds to the number of letters in the value attribute? Should it be val().length() or something? Thanks for your help! Cheers, Dug On Dec 31, 12:06 pm, Kelvin Luck <[EMAIL PROTECTED]> wrote: > Hi, > > You could try this (untested): > > $('[EMAIL PROTECTED]').each( > function() > { > $this = $(this); > if ($this.val() < 5) { > $this.addClass('S'); > } else if ($this.val() > 10) { > $this.addClass('L'); > } else { > $this.addClass('M'); > } > } > ); > > Hope that helps, > > Kelvin :) > > Dug Falby wrote: > > Hi all, > > > I'd like to do the following: > > > walk through the DOM stopping at: > > > [EMAIL PROTECTED] > > > and conditionally add a class to each input tag: > > > if [EMAIL PROTECTED]() < 5 then .addClass('S') > > if [EMAIL PROTECTED]() > 10 then .addClass('L') > > else .addClass('M') > > > Can I still use the lovely $() construct? > > > Thanks:-) > > Dug