JQuery User Manual (iv) _ jquery

Source: Internet
Author: User
JQuery user manual. You can read it patiently and get started. Thu:JavaScript processing

$. Browser () determines the browser type and returns the boolen Value $ (Function(){
If($. Browser. msie ){
Alert ("This is an Internet browser.");}
Else If($. Browser. opera ){
Alert ("This is an operabrowser.");}
})When the page load type determines the browser type, the types that can be determined include msie, mozilla, opera, and safari.

$. Each (obj, fn)Obj is an object or array, and fn is a function executed in sequence on obj. Note that $ (). each () is distinguished () $. Each ([0,1,2],Function(I) {alert ("Item #" +I+ ":" + This);});Input 0, 1, 2 as parameters to function (I) respectively.$. Each ({name:"John", Lang:"JS"},Function(I) {alert ("Name:" +I+ ", Value:" + This);{Name: "John", lang: "JS"} is a hash object. Each group of hash objects is input to the function in sequence.

$. Extend (obj, prop)Extend the first object with the second object VarSettings={Validate:False, Limit:5, Name:"Foo"};
VarOptions={Validate:True, Name:"Bar"};
$. Extend (settings, options );After execution, the settings object is {validate: true, limit: 5, name: "bar "}
You can use the following function to test$ (Function(){
VarSettings={Validate:False, Limit:5, Name:"Foo"};
VarOptions={Validate:True, Name:"Bar"};
$. Extend (settings, options );
$. Each (settings,Function(I) {alert (I+ "=" + This);});
})
$. Grep (array, fn)Use the fn function to filter the array. Pass the elements in the array to fn in sequence. The fn must return a boolen. If fn returns true, it will be filtered. $ (Function(){
VarArr=$. Grep ([0,1,2,3,4],Function(I ){ReturnI> 2;});
$. Each (arr,Function(I) {alert (I );});
})We can see that the array [, 4] After $. grep is executed becomes [].

$. Merge (first, second)Both parameters are arrays. The second array is the same as the first one, and then the two arrays are merged. $ (Function(){
VarArr=$. Merge ([0,1,2], [2,3,4])
$. Each (arr,Function(I) {alert (I );});
})The result of arr is [0, 1, 2, 3, 4].

$. Trim (str)Removes spaces at both ends of a string.
$. Trim ("hello, how are you? ") The result is" hello, how are you? "
Related Article

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.