zepto入门以及与jQ的区别

 

后置  、前置插入

第一个包裹是分别包裹,第二个是全都包裹到一个里面

 

开头的简写方式

 

 

 

 

点击a就会冒泡

true为事件捕获

 

 

 

命名空间可以解绑分支事件

 

 

 AJAX  前后端的桥梁

传统AJAX

 

zepto中的Ajax

一般返回json 简化后

移动端使用touch

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1,initial-scale=1,user-scalable=0">
    <title>zepto!>>touch</title>
</head>
<body>
    <div id="touch-test" style="font-size:36px;width:200px;height:200px;background:#cce">
        touch events test
    </div>
    <script type="text/javascript" src="./lib/zepto.min.js"></script>
    <script type="text/javascript" src="./lib/touch.js"></script>
    <script>
        $(document).ready(function(){
            $('#touch-test').bind('touchmove',function(e){e.preventDefault()})

            listen_to('#touch-test')

            function listen_to(el){
                $(el).tap(function(){
                    console.log(' |tap!')
                })
                .doubleTap(function(){
                    console.log(' |doubleTap!')
                })
                .swipe(function(){
                    console.log('swipe')
                })
                .swipeLeft(function(){
                    console.log('swipe')
                })
                .swipeRight(function(){
                    console.log('swipe')
                })
                .swipeUp(function(){
                    console.log('swipe')
                })
                .swipeDown(function(){
                    console.log('swipe')
                })
                .longTap(function(){
                    console.log('swipe')
                })
                .singleTap(function(){
                    console.log('swipe')
                })
            }
        });

    </script>

</body>
</html>

简单插件的使用

不填参数就是默认值的写法

 

 

函数末尾加入return this 就可以链式调用了

 

多组插件

 

 

 

可以讲上面的函数封装到一个文件当中然后就可以直接倒入插件了

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值