首页 > Windows开发 > 详细

Zepto API 学习

时间:2016-06-07 12:35:24      阅读:205      评论:0      收藏:0      [点我收藏+]

1: $.inArray
  $.inArray(‘2‘, [3, ‘2‘, 10]) 1
  $.inArray(‘2‘, [3, ‘22‘, 10]) -1
  Get the position of element inside an array

2: $.map
  $.map([2,3,8], function(item, index){ if(item > 2)return item; })

3: children find parent parents closest 区别
  children 找的是直接的所有子元素
  find 找的是所有子元素
  parent 查找的直接一个父级元素
  parents 查找的所有父级元素
  closest 查找的所有父级元素的第一个

4: CSS 方法
  $(‘body‘).css([‘backgroundColor‘, ‘fontSize‘, ‘color’])
  返回: {backgroundColor: "", fontSize: "", color: "rgb(0, 0, 0)"}

5: zepto-1.1.6.js 和 jquery-1.12.4.js 下, 如果是"空数组"覆盖不了"非空数组"的值。

var obj = {a: {b: [1,2]} };
var obj2 = {a: {b: []} };
$.extend(true, obj, obj2);
//obj 没变: {a: {b: [1,2]} }, 覆盖不了

var obj = {a: {b: [1,2]} };
var obj2 = {a: {b: [3]} };
$.extend(true, obj, obj2);
//obj 变了: {a: {b: [3,2]} }

var obj = {a: {b: {a: 1}} };
var obj2 = {a: {b: []} };
$.extend(true, obj, obj2);
// obj 变了: {a: b: []}, 由于一个是数组,一个是对象,所以全部覆盖了

 

 

Zepto API 学习

原文:http://www.cnblogs.com/zhengming2016/p/5566496.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!