zoukankan      html  css  js  c++  java
  • $.extend()

    jQuery.extend扩展函数的用法(没有的新加,已有的覆盖

    • 扩展jquery静态方法
    $.extend({
        test:function(){alert('test函数')}
    })

    用法: $.test()

    • 合并多个对象
    //用法: jQuery.extend(obj1,obj2,obj3,..)
    var Css1={size: "10px",style: "oblique"}
    var Css2={size: "12px",style: "oblique",weight: "bolder"}
    $.jQuery.extend(Css1,Css2)
    //结果如下:Css1的size属性被覆盖,而且继承了Css2的weight属性
    //Css1 = {size: "12px",style: "oblique",weight: "bolder"}
    • 深度嵌套对象

    新的extend()允许你更深度的合并镶套对象。下面的例子是一个很好的证明。

    // 以前的 .extend() jQuery.extend( { name: “John”, location: { city: “Boston” } }, { last: “Resig”, location: { state: “MA” } } ); // 结果: // => { name: “John”, last: “Resig”, location: { state: “MA” } }

    // 新的更深入的 .extend() jQuery.extend( true, { name: “John”, location: { city: “Boston” } }, { last: “Resig”, location: { state: “MA” } } ); // 结果 // => { name: “John”, last: “Resig”, // location: { city: “Boston”, state: “MA” } }

  • 相关阅读:
    C语言函数qsort的使用方法
    成绩打分
    distance.c
    留学生题目
    6大排序算法比较
    小游戏得分[石头剪刀布]
    二叉排序树算法
    头文件相关
    小型考试系统
    小题目【链表1】
  • 原文地址:https://www.cnblogs.com/chrisghb8812/p/6094391.html
Copyright © 2011-2022 走看看