jQuery相关用法

#jquery中extend的用法 [1] [2]
jQuery.extend( target [, object1 ] [, objectN ] )
Description: Merge the contents of two or more objects together into the first object.

jQuery.extend( [deep ], target, object1 [, objectN ] )
  deep 
  Type: Boolean
  If true, the merge becomes recursive (aka. deep copy). Passing false for this argument is not supported.

var result=$.extend( true, {}, 
{ name: "John", location: {city: "Boston",county:"USA"} }, 
{ last: "Resig", location: {state: "MA",county:"China"} } );

src1中嵌套子对象location:{city:"Boston"},src2中也嵌套子对象location:{state:"MA"},第一个深度拷贝参数为true,那么合并后的结果就是: 
result={name:"John",last:"Resig",location:{city:"Boston",state:"MA",county:"China"}}
也就是说extend会将src中的嵌套子对象也进行合并。

而如果第一个参数boolean为false,结果如下:
result={name:"John",last:"Resig",location:{state:"MA",county:"China"}}

#新建元素
$("<div>")


#jquery事件命名空间 [1] [2] [3] [4] [5]
$(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) 这里面的"click.bs.alert.data-api"的专业术语是叫"事件命名空间",主要作用是方便在自定义事件时可以准确的解除事件绑定。比如一个div用on()绑定了click和自定义的click.alert事件,在通过off()解除click.alert事件时不会影响click事件的绑定。 

posted on 2017-08-31 10:29  dream_bccb  阅读(141)  评论(0)    收藏  举报