zoukankan      html  css  js  c++  java
  • 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 ) (去除空格)
  • 相关阅读:
    一周自学动态站点设计
    【甘道夫】Apache Hadoop 2.5.0-cdh5.2.0 HDFS Quotas 配额控制
    linux系统管理命令--系统测试工具
    Atitit.异步编程 java .net php python js 对照
    项目开发经常使用PHP功能
    它们的定义app.config中间section节点和在执行中使用
    Android 它们的定义ListView实现底部和页下拉刷新刷新的顶
    vs2012连接sql2008(错误类型:Could not load file or assembly)
    管理不,因为你不是说经理
    java编程接口(5) ------ button和button组
  • 原文地址:https://www.cnblogs.com/flowerszhong/p/1950636.html
Copyright © 2011-2022 走看看