How jquery can strictly transform the parameter list into a group of implementation ideas _jquery

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.