each iterates over the elements of a given array. Since a string is an array of characters (try alert("bar"[1]) if you don't believe it), each is iterating over each character. Maybe try splitting the classes on space characters? Maybe something like this:
$.each(foo.className.split(' '), ...); --Erik On 7/26/07, pd <[EMAIL PROTECTED]> wrote: > > > Hi All > > I'm trying to iterate through a DOM object's class values to develop > a form validation routine. At the moment the $.each() function is > treating each and every character in the class value as a separate > item, instead of splitting the values into separate values based on > spaces. Therefore this doesn't really work: > > var fieldClasses = parsedInField.className; > > or > > var fieldClasses = $(parsedInField).attr('class'); > > > > $.each( fieldClasses , > > function (count, clarse) { > > if (clarse == 'alphanum') { > > // blah > > } else if (clarse == 'numeric') { > > // blah > > } > > } > > ); > > Can anyone confirm if this should work? If so am I missing something? > It is later on Friday afternoon down here in Australia :) Not the > best of time for concentrating. > > Example (not so clean, sorry) is here: > > http://devel.webutils.vicnet.net.au/ > > Any help would be immensely appreciated. > > Thanks > pd > >