JavaScript handling of the jquery user manual

Source: Internet
Author: User

$.browser () function, I hope I have not called the wrong. The purpose is: To determine the browser type, return Boolen value

$ (function () {

if ($.browser.msie) {

Alert ("This is an IE browser");}

else if ($.browser.opera) {

Alert ("This is an opera browser");}

})

When page loading determines browser type, there are several types of browsers that can be judged by MSIE, Mozilla, Opera, Safari

$.each (obj, fn) http://www.mlybyby.com

Obj is an object or an array, and FN is the function executed sequentially on OBJ, noting the distinction of $ (). each ()

$.each ([0,1,2], function (i) {alert ("Item #" + i + ":" + This);});

The 0,1,2 is passed into function (i), respectively, as a parameter.

$.each ({name: "John", Lang: "JS"}, function (i) {alert ("Name:" + i + ", Value:" + this);

{Name: "John", Lang: "JS"} is a hash object, in turn, each group of objects in the hash is passed into the function

$.extend (obj, prop)

Extend the first object with a second object

var settings = {validate:false, limit:5, Name: "foo"};

var options = {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 () {

var settings = {validate:false, limit:5, Name: "foo"};

var options = {validate:true, name: "Bar"};

$.extend (settings, options);

$.each (settings, function (i) {alert (i + "=" + This);});

})

$.grep (ARRAY,FN)

By using the function FN to filter the array, passing the elements in the array to FN,FN must return a boolen, such as FN returns True, will be filtered

$ (function () {

var arr= $.grep ([0,1,2,3,4], function (i) {return i > 2;});

$.each (arr, function (i) {alert (i);});

})

We can look at the execution $.grep after the array [0,1,2,3,4] becomes [0,1]

$.merge (first, second)

The two parameters are arrays, the second array is the same as the first one, then the two numbers are combined and

$ (function () {

var arr = $.merge ([0,1,2], [2,3,4])

$.each (arr, function (i) {alert (i);});

})

You can see that the result of ARR is [0,1,2,3,4]

$.trim (str)

Remove spaces at both ends of a string

$.trim ("Hello, how is You?")

The result is "Hello, how is it?"

JavaScript handling of the jquery user manual

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.