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 

    去除前后空格

  • 相关阅读:
    JQuery 图片轮播
    js版的虚线框
    折叠菜单,选择下拉(手风琴)
    logstash的index值可以为中文
    假如正则从来没来过,我们该如何去匹配一个字符串?
    深度解析javascript中的浅复制和深复制
    笔试题
    前端笔试题总结---持续更新
    清除浮动
    一步一步的理解闭包
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5122180.html
Copyright © 2011-2022 走看看