If the column of a parameter has only one argument, then each fails, see the example below
Java code:
Copy Code code as follows:
<! DOCTYPE html>
<style>
p {margin:8px; font-size:16px;}
. Selected {color:red}
. Highlight {Background:yellow}
</style>
<script src= "Http://code.jquery.com/jquery-latest.js" ></script>
<body>
Hello
and
Goodbye
Script with style implements the Modify style in the script.
<script>
var pp=3;
var a=[pp];
alert (a);
$.each (Pp,function (i,n) {
alert (i);
});
</script>
</body>
The result is that the first alert is 3, the second without alert, which means that PP is not an array, Dom,jason, etc.
How to ensure that the PP is strictly an array, very simple var a=[pp]; This is the line, we'll replace each of the PP with a, the result is 3, 0, correct. Notice that the brackets convert the PP into an array.
Java code:
Copy Code code as follows:
<! DOCTYPE html>
<style>
p {margin:8px; font-size:16px;}
. Selected {color:red}
. Highlight {Background:yellow}
</style>
<script src= "Http://code.jquery.com/jquery-latest.js" ></script>
<body>
Hello
and
Goodbye
Script with style implements the Modify style in the script.
<script>
var pp=3;
var a=[pp];
alert (a);
$.each (A,function (i,n) {
alert (i);
});
</script>
</body>
Summary: When the number of parameters is less than 2 o'clock, to strictly ensure that the parameters listed in the array, strict each to perform each operation, you need to the length of the parameter column is greater than 2 to treat separately.