zoukankan      html  css  js  c++  java
  • 阅读zepto.js的core中的Core methods

    学习zepto.js,參考资料:http://www.zeptojs.cn/

    跟jQuery一样。其选择符号也是$;

    首先接触的是

    $.()  选择

    $(selector, [context])   ⇒ collection
    $(<Zepto collection>)   ⇒ same collection
    $(<DOM nodes>)   ⇒ collection
    $(htmlString)   ⇒ collection
    Zepto(function($){ ... })  
    $('div')  //=> all DIV elements on the page
    $('#foo') //=> element with ID "foo"
    
    // generate elements from HTML
    $("<p>Hello</p>") //=> the orphaned P element
    
    // execute function when the page is ready
    Zepto(function($){
      alert('Ready to Zepto!')
    })

    $.each 遍历数组和对象

    $.each(['a', 'b', 'c'], function(index, item){
      console.log('item %d is: %s', index, item)
    })
    
    var hash = { name: 'zepto.js', size: 'micro' }
    $.each(hash, function(key, value){
      console.log('%s: %s', key, value)
    })

    $.extend 扩展对象

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

    $.inArray v1.0+

    从某个下标開始 查询元素在数组中的下标,没有符合条件的 则返回-1
    $.inArray(element, array, [fromIndex])   ⇒ number

    $.isArray

    推断一个对象是否是数组

    $.isFunction

    $.isPlainObject

    $.map

    也是用于遍历的方法,自己主动过滤掉。空的或没有定义的值

    $.trim 

    去除前后空格

  • 相关阅读:
    Java 测试代码模板
    git 保存用户名和密码
    git 高级命令
    git 最常用命令
    git 冲突解决
    git diff命令
    nginx静态服务器的配置
    使用SFTP工具下载文件
    git log 格式化输出
    9-angular.fromJson
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5122180.html
Copyright © 2011-2022 走看看