Zepto 與 jQuery 的區別 小結

1. Zepto 對象 不能自定義事件數組

例如執行: $({}).bind('cust', function(){});瀏覽器

結果: TypeError: Object has no method 'addEventListener'spa

解決辦法是建立一個脫離文檔流的節點做爲事件對象:orm

例如: $('對象

').bind('cust', function(){});

2. Zepto 的選擇器表達式: [name=value] 中value 必須用 雙引號 " or 單引號 ' 括起來事件

例如執行:$('[data-userid=123123123]')ci

結果:Error: SyntaxError: DOM Exception 12文檔

解決辦法: $('[data-userid="123123123]"') or $("[data-userid='123123123']")get

3.Zepto 是根據標準瀏覽器寫的,因此對於節點尺寸的方法只提供 width() 和 height(),省去了 innerWidth(), innerHeight(),outerWidth(),outerHeight()it

4.Zepto 的each 方法只能遍歷 數組,不能遍歷JSON對象 5.Zepto 的animate 方法參數說明 :

例如:$("data-userid='123123123'").animate({ opacity : 0},{duration:'slow'});

duration : 'slow' 是無效的,須要修改成 duration : 600

相關文章
相關標籤/搜索