$.each($("input:hidden"), function(i,val){ alert(val); //Output [object HTMLInputElement] because it is a form element. alert(i); //The output index is 0, 1, 2, 3 alert(val.name); //Output the value of name alert(val.value); //Output value The value of Iteration method can be used to iterate objects and arrays.
Unlike the $().each() method that iterates over jQuery objects, this method can be used to iterate over any object. The callback function has two parameters: the first is the member of the object or the index of the array, and the second is the corresponding variable or content. If you need to exit the each loop, you can make the callback function return false, and other return values will be ignored.
Parameters objectObject The object or array to be traversed.
callback (optional)Function Callback function executed by each member/element.
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn