zoukankan      html  css  js  c++  java
  • touch事件

    可封装的js代码

    if (typeof YwkMobile == "undefined") var YwkMobile = {};
    YwkMobile.touchStyle = function(e, t) {
    $(e).bind("touchstart",
    function() {
    $(this).addClass(t)
    }),
    $(e).bind("touchmove",
    function() {
    $(this).removeClass(t)
    }),
    $(e).bind("touchend",
    function() {
    $(this).removeClass(t)
    }),
    $(e).bind("touchend",
    function() {
    $(this).removeClass(t)
    }),
    $(e).bind("touchcancel",
    function() {
    $(this).removeClass(t)
    })
    },
    YwkMobile.gotoDetail = function(e, t) {
    $(e).bind("click",
    function() {
    window.location.href = $(this).attr(t)
    })
    }
    //

    html中调用方法

    //touch事件
    $(function(){
    YwkMobile.touchStyle('.navlist li a ,.product-list li','mtouchs');
    });

    css

    添加类mtouchs可以写成touch事件触摸后的样式

    .product-list li.mtouchs{}

    是添加类mtouchs,所以中间不能有空格












  • 相关阅读:
    HDU
    HDU
    HDU
    HDU
    西电网络赛
    西电网络赛
    西电网络赛
    西电网络赛
    西电网络赛
    西电网络赛
  • 原文地址:https://www.cnblogs.com/snowbaby-kang/p/3781670.html
Copyright © 2011-2022 走看看