zepto点击事件兼容pc和mobile
生活随笔
收集整理的這篇文章主要介紹了
zepto点击事件兼容pc和mobile
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
判斷pc還是mobile,重寫click事件
var CLICK='click'; (function browserRedirect() {var sUserAgent = navigator.userAgent.toLowerCase();var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";var bIsMidp = sUserAgent.match(/midp/i) == "midp";var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";var bIsAndroid = sUserAgent.match(/android/i) == "android";var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM){CLICK='tap';alert("iphone");}else{alert("pc")} }());使用:
function clicktabs(tit_id, box_id, cur) {var g_tags = $(tit_id),g_conts = $(box_id),g_current = cur;g_tags[CLICK](function(){}) }
?
轉載于:https://www.cnblogs.com/xupeiyu/p/5067038.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的zepto点击事件兼容pc和mobile的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 类似百度输入框自动完成
- 下一篇: python列表常用方法