1.$() 的用法。
  获取元素
    $('div') //获取所有页面中的div元素
    $('#foo') // 获取ID 为"foo"的元素
  创建元素
    $("<p>Hellow</p>"") //新的p元素
    $("<p/>",{text:"Hellow",id:"greeting",css:{color:'darkblue'}}) //<p id="greeting" style="color:darkblue">Hellow</p>
  当页面ready的时候,执行回调:
    Zepto(function($){
      alert("123")
    })

2.camelCase

   将一组字符串变成“驼峰”命名法的新字符串,如果该字符串已经是驼峰命名,那么不变。
    $.camelCase('hello-there') //“helloThere”
    $.camelCass('helloThere') // "helloThere"

3.$.contains()

   检查父节点是否包含给定的dome 节点,如果两者是相同的节点,则返回 false.
  用法:$.contains(parent,node) 返回 boolean

4.each
  $.each(collection,function(indx,item){...})
  遍历数组元素或者以key-value 值对方式遍历对象。回调换上返回false 时停止遍历。

    $.each(['a','b','c'],function(index,item){
      console.log('item %d is: %s',index,item)
    })
      //item 0 is: a
      //ct1.html:18 item 1 is: b
      //ct1.html:18 item 2 is: c

  var hah = {name:'zepto.js',size:'micro'}
    $.each(hash,function(key,vaue){
      console.log('%s: %s',key,value)
    })
    //name: zepto.js
    //size: micro

5.$.extend
  $.extend(target,[source,[source2,...]])
  $.extend(true,target,[source,.....])
  通过源对象扩展目标对象的属性,源对象属性将覆盖目标对象属性
  默认情况下为,复制为浅拷贝,如果第一个参数为true表示深度拷贝(深度复制)

    var target = {one:'patridge'},
    source = {two:'turtle doves'}
    console.log($.extend(target,source))
    //{one: "patridge", two: "turtle doves"}

6.fn
  Zepto.fn 是一个对象,它拥有Zepto对象上所有的方法,在这个对象上添加一个方法。
  所有的Zepto 对象上都能用到这个方法。
    $.fn.empty = function(){
      return this.each(function(){ this.innerHTML=''})
    }

7.grep
  $.grep(items,function(item){...}) 类型array
    获取一个新数组,新数组只包含回调函数中返回true 的数组项
    $.grep([1,2,3],function(item){
      return item > 1
    );
      //=>[2,3]

8.inArray
  $.inArray(element,array,[fromIndex]) 类型:number
  返回数组中指定元素的索引值,如果没有找到该元素则返回 -1.
  [fromIndex] 参数可选,表示从哪个索引值开始向后搜索。
    $.inArray("abc",["bcd","abc","edf","aaa"]);
      //=>1
    $.inArray("abc",["bcd","abc","edf","aaa"],1);
      //=>1
    $.inArray("abc",["bcd","abc","edf","aaa"],2);
      //=>-1

9.isArray
  $.isArray(object) 类型:boolean
  如果object 是array ,则返回true.
  var ob = [1,2,3,4];
    console.log($.isArray(ob))
      //true

10.isFunction
  $.isFunction(object) 类型 boolean
  如果object 是function,则返回true.
    var fun = function(){ return 123;}
    console.log($.isFunction(fun))
      //true

11.$.isPlainObject
    $.isPlainObject(object) 类型:boolean
    测试对象是否是纯粹的对象,这个对象是通过对象常量("{}")或者new Object 创建的,如果是,则返回true.
      $.isPlainObject({})
        // => true
      $.isPlainObject(new Object)
        // => true
      $.isPlainObject(new Date)
        // => false
      $.isPlainObject(window)
        // => false

12.isWindow
  $.isWindow(object) 类型;boolean
  如果object 参数是否为yige window 对象,那么返回true.这在处理iframe 时非常有用,因为每个iframe都有他自己的window对象,

  使用常规方法 obj=== window 验证这些objects时候会失败。

13.$.map
  $.map(collection,function(item,index){...}) 类型 collection
  通过遍历集合中的元素,返回通过迭代函数的全部结果,null和undefined 将被过滤掉。
  $.map([1,2,3,4,5],function(item,index){
    if(item>1){return item*item;}
  });
    // =>[4, 9, 16, 25]
  $.map({"yao":1,"tai":2,"yang":3},function(item,index){
    if(item>1){return item*item;}
  });
    // =>[4, 9]

14.$.parseJSON
    $.parseJSON(string) 类型:object
    原生 JSON.parse 方法的别名。接受一个标准格式的JSON 字符串,并返回解析后的JavaScript 对象。

15.trim
    $.trim(string) 类型: string
    删除字符串收尾的空白符,类型String.prototype.trim()

16.type
  $.type(object) 类型:string
  获取JavaScript 对象的类型,可能的类型有:null undefined boolean number string function array date regexp object error.
  对于其它对象,他只是简单报告为”object“,如果你想知道一个对象是否是一个javascript普通对象,使用isPlainObject.

17.add
  add(selector,[context]) 类型: self
  添加元素到当前匹配的元素集合中,如果给定content 参数,将只在content 元素中进行查找,否则在整个document 中查找。
  $('li').add('p').css('background-color', 'red');

18.addClass
  addClass(name) 类型:self
  addClass(function(index, oldClassName){....})
  为每个匹配的元素添加指定的class类名。多个class类名使用空格分隔。

19.after
  after(content) 类型 :self
  在每个匹配的元素后面插入内容(外部插入)内容可以为html字符串,dom节点,或者节点组成的数组。
  $.('form label').after('<p>A note below the label</p>')

20.append
  append(content) 类型:self
  在每个匹配的元素末尾插入内容(内部插入)。内容可以为html 字符串。dom节点,或者节点组成的数组。
  $('ul').append('<li>new list item</li>')

zepto 基础知识(1)的更多相关文章

  1. zepto 基础知识(3)

    41.height height() 类型:number height(value) 类型:self height(function(index,oldHeight){...}) 类型:self 获取 ...

  2. zepto 基础知识(6)

    101.$.ajax $.ajax(options) 类型:XMLttpRequest 执行Ajax请求.他可能是本地资源,或者通过支持HTTP access control的浏览器 或者通过 JSO ...

  3. zepto 基础知识(5)

    81.width width() 类型:number width(value) 类型:self width(function(index,oldWidth){....}) 类型:self 获取对象集合 ...

  4. zepto 基础知识(4)

    61.prev prev() 类型:collection prev(selector) 类型:collection 获取对相集合中每一个元素的钱一个兄弟节点,通过选择器来进行过滤 62.prev pr ...

  5. zepto 基础知识(2)

    20.append append(content) 类型:self 在每个匹配的元素末尾插入内容(内部插入).内容可以为html 字符串.dom节点,或者节点组成的数组. $('ul').append ...

  6. .NET面试题系列[1] - .NET框架基础知识(1)

    很明显,CLS是CTS的一个子集,而且是最小的子集. - 张子阳 .NET框架基础知识(1) 参考资料: http://www.tracefact.net/CLR-and-Framework/DotN ...

  7. RabbitMQ基础知识

    RabbitMQ基础知识 一.背景 RabbitMQ是一个由erlang开发的AMQP(Advanced Message Queue )的开源实现.AMQP 的出现其实也是应了广大人民群众的需求,虽然 ...

  8. Java基础知识(壹)

    写在前面的话 这篇博客,是很早之前自己的学习Java基础知识的,所记录的内容,仅仅是当时学习的一个总结随笔.现在分享出来,希望能帮助大家,如有不足的,希望大家支出. 后续会继续分享基础知识手记.希望能 ...

  9. selenium自动化基础知识

    什么是自动化测试? 自动化测试分为:功能自动化和性能自动化 功能自动化即使用计算机通过编码的方式来替代手工测试,完成一些重复性比较高的测试,解放测试人员的测试压力.同时,如果系统有不份模块更改后,只要 ...

随机推荐

  1. js Base64与字符串互转

    1.base64加密 在页面中引入base64.js文件,调用方法为: <!DOCTYPE HTML> <html> <head> <meta charset ...

  2. 一分钟学会Git操作流程

    今天整理下公司操作git 流程,尽量用最最简洁的方式整理出来,方便以后有新来的同事学习使用. 我整理的这个Git操作,基本上只需要一分钟,就可以轻松上手啦!!! 一. 拉取提交操作 1.拉取远程代码 ...

  3. java中try-catch-finally中的return语句

    在try-catch-finally语句中使用return语句遇到了一些疑问 代码一: static int intc(){ int x =0; try{ x=1; return x; }finall ...

  4. scss-嵌套规则

    在编写css代码的时候,可能由于嵌套的原因,需要多次重复书写选择器. 代码如下: #content article h1 { color: #333 } #content article p { ma ...

  5. angular.uirouter

    首先给大家介绍angular-ui-router的基本用法.如何引用依赖angular-ui-router angular.module('app',["ui.router"]). ...

  6. [转载]AMOLED结构详解,BOE专家给你分析驱动补偿

    关键词: AMOLED, 驱动补偿 有机发光显示二极管(OLED)作为一种电流型发光器件已越来越多地被应用于高性能显示中.由于它自发光的特性,与LCD相比,AMOLED具有高对比度.超轻薄.可弯曲等诸 ...

  7. SQLServer存储过程 实例,很多语法可以以后参考

    SQL代码 alter PROCEDURE sp_addnewdtgtype ( ), @dtgdllcontent image, ) ) AS BEGIN ); declare @v_count i ...

  8. HCNA多区域OSPF配置

    1.拓扑图 2.各路由器配置角本 ospf 多区域配置 #R5配置 sys sysname AR5 interface s2// ip add 10.0.35.5 255.255.255.0 inte ...

  9. June 16th 2017 Week 24th Friday

    Progress is the activity of today and the assurance of tomorrow. 进步是今天的活动,明天的保证. The best preparatio ...

  10. php多进程写入文件

    测试一 $begin = time(); for ($i=0; $i<10000; $i++) { $fp = fopen("tmp", 'r+'); fseek($fp, ...