You should definitely consider using a classname to select items like this. $('input.quantity') would be significantly faster.
On May 22, 8:29 am, Gordon <[EMAIL PROTECTED]> wrote: > I am writing a script that scans a list of items that each contain > form fields and doing something based on the value of the field in > each item. I came up with the following code, which does seem to work > as intended, but execution can take upwards of 500ms, which I feel is > rather slow. > > var container = '#myElem'; > > $(container.children ()).each (function () > { > thisVal = parseInt ($('[EMAIL PROTECTED]"quantity"]', this).attr > ('value'), > 10); > // Do stuff > > }); > > Obviously the fields can't have the same ID as that would break the > validity of the HTML. Field names do not have to be unique so it > seemed logical to use them as the basis of selecting the collection of > elements to work with.