If a parameter column has only one parameter, then each fails, please see the example below
Java code:
Hello
and
Goodbye
Script works together with style to modify the style in script.
<script> <br>var pp=3; <br>var a=[pp]; <br>alert(a); <br>$.each(pp,function(i,n){ <br>alert(i); <br>}); <br></script>
The result is first The first alert is 3, and the second time there is no alert, indicating that pp is not an array, dom, Jason, etc.
How to ensure that pp is strictly an array? It is very simple: var a=[pp]; this sentence will do. Next, we replace pp in each with a, and the result is 3,0, which is correct. Note that the square brackets convert pp into an array.
Java code:
Hello
and
Goodbye
script works together with style to modify the style in script.
<script> <br>var pp=3; <br>var a=[pp]; <br>alert(a); <br>$.each(a,function(i,n){ <br>alert(i); <br>}); <br></script>
Summary: When parameters When the number is less than 2, it is necessary to strictly ensure that the parameter column is an array, and each operation must be strictly performed. If the parameter column length is greater than 2, it needs to be treated separately.