jquery静态方法

jQuery.browser (safari,opera,msie,mozilla)
jQuery.browser.version
jQuery.boxModel
jQuery.each( object, callback )
jQuery.extend( target, object1, [objectN] ) (修改值)
jQuery.grep( array, callback, [invert] ) (剔除)
jQuery.makeArray( obj ) (生成数组)
jQuery.map( array, callback ) (自定义处理数组)
jQuery.inArray( value, array ) (查找 -1:找不到)
jQuery.unique( array ) (去重)
jQuery.isFunction( obj ) (是否是函数)
jQuery.trim( str ) (去除空格)


1.User Agent

        jQuery.browser (safari,opera,msie,mozilla)
                $.browser.msie
                jQuery.each(jQuery.browser, function(i, val) {
                  $("<div>" + i + " : <span>" + val + "</span>")
                            .appendTo(document.body);
                });

        jQuery.browser.version (版本)
                Internet Explorer: 6.0, 7.0
                Mozilla/Firefox/Flock/Camino: 1.7.12, 1.8.1.3, 1.9
                Opera: 9.20
                Safari/Webkit: 312.8, 418.9

        jQuery.boxModel (是否使用W3C模型)


2.Array and Object operations

        jQuery.each( object, callback )
                var arr = [ "one", "two", "three", "four", "five" ];
                var obj = { one:1, two:2, three:3, four:4, five:5 };

                jQuery.each(arr, function() {
                  $("#" + this).text("My id is " + this + ".");
                  return (this != "four"); // will stop running to skip "five"
                });

                jQuery.each(obj, function(i, val) {
                  $("#" + i).append(document.createTextNode(" - " + val));
                });

        jQuery.extend( target, object1, [objectN] ) (修改值)
                var settings = { validate: false, limit: 5, name: "foo" };
                var options = { validate: true, name: "bar" };
                jQuery.extend(settings, options);

        jQuery.grep( array, callback, [invert] ) (剔除)
                var arr = [ 1, 9, 3, 8, 6, 1, 5, 9, 4, 7, 3, 8, 6, 9, 1 ];
                $("div").text(arr.join(", "));

                arr = jQuery.grep(arr, function(n, i){
                  return (n != 5 && i > 4);
                });
                $("p").text(arr.join(", "));

                arr = jQuery.grep(arr, function (a) { return a != 9; });
                $("span").text(arr.join(", "));

        jQuery.makeArray( obj ) (生成数组)
                var arr = jQuery.makeArray(document.getElementsByTagName("div"));
                arr.reverse(); // use an Array method on list of dom elements
                $(arr).appendTo(document.body);

        jQuery.map( array, callback ) (自定义处理数组)
                var arr = [ "a", "b", "c", "d", "e" ]
                $("div").text(arr.join(", "));

                arr = jQuery.map(arr, function(n, i){
                  return (n.toUpperCase() + i);
                });
                $("p").text(arr.join(", "));

                arr = jQuery.map(arr, function (a) { return a + a; });
                $("span").text(arr.join(", "));

        jQuery.inArray( value, array ) (查找 -1:找不到)
                var arr = [ 4, "Pete", 8, "John" ];

                $("span:eq(0)").text(jQuery.inArray("John", arr));
                $("span:eq(1)").text(jQuery.inArray(4, arr));
                $("span:eq(2)").text(jQuery.inArray("David", arr));

        jQuery.unique( array ) (去重)

                jQuery.unique(divs)


3.Test operations

        jQuery.isFunction( obj ) (是否是函数)
                function stub() {
                }
                var objs = [
                      function () {},
                      { x:15, y:20 },
                      null,
                      stub,
                      "function"
                    ];

                jQuery.each(objs, function (i) {
                  var isFunc = jQuery.isFunction(objs[i]);
                  $("span:eq( " + i + ")").text(isFunc);
                });


4.String operations

        jQuery.trim( str ) (去除空格)

你可能感兴趣的:(jquery)