I would consider the code suspect - and prone to fail - because the wrong "each" is being used. (But who knows; surprising things can happen.)
There is jQuery.each (e.g. $.each(array, ..)
), which is being used:
A generic iterator function, which can be used to seamlessly iterate over both objects and arrays.
And .each (e.g. $(selector).each(..)
), which should be used:
Iterate over a jQuery object, executing a function for each matched element.
In this case, use .each
to iterate over the jQuery object, such as:
todosOsCampos.each(function(){ .. })
Remember that $(selector)
always returns a jQuery object which is a collection of 0 or more elements matched.
If problems persist after correcting the usage, update the post with more details including warning/error messages.