$(function(){ $('[EMAIL PROTECTED]').each(function() { var len = this.value.length; $(this).addClass(len<5?'S':len>10?'L':'M'); }); });
Change the 5 and/or 10 to the appropriate limits. On Dec 31 2007, 11:52 am, "Dug Falby" <[EMAIL PROTECTED]> 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 > > -- > Dug Falby > +44 75 15 66 16 55http://www.donkeyontheedge.com/