From the PC end to the mobile end to believe that many front-end siege to the mobile end, write the original soundtrack of the phone-side event is very laborious, and JQ Click has 300 milliseconds delay, now has a relatively good JQ plug-in hammer, Hammer.js is an open source, lightweight JavaScript library, it can be no need to rely on other things to identify the touch, mouse events to support a variety of mobile phone events, such as scaling, QQ left sliding delete, magnification, rotation and so on.
The following is a tab switch to introduce hammer.
Usage:
1, first introduce jq2.0 above version and Jquery.hammer.js.
2, get the element, same as JQ, add hammer at the back to the var Hammertime = $ ('. Tabs a '). Hammer ();
3, you can add event Hammertime.on (' Tap ', function (EV) {}) directly with on to use the tap-click event in Hammer. function can write their own JS.
Hammer.dragstart = function (EV) {};//start dragging </span>
Hammer.drag = function (ev) {};//drag in </span>
Hamm Er.dragend = function (ev) {}; Drag end </span>
hammer.onswipe = function (ev) {};//sliding </span>
Hammer.tap = function (ev) {};//click ;/span>
Hammer.doubletap = function (EV) {}//double-click </span>
hammer.hold = function (EV) {};//long press </span& gt;
Hammer.release = function (ev) {}; Finger off Screen </span>
Experience Link: http://hammerjs.github.io/
JS Code
$ (function () {
var hammertime = $ ('. Tabs a '). Hammer ();
Hammertime.on (' Tap ', function (EV) {
$ (this). addclass (' actives '). Siblings (). Removeclass (' actives '); Adds a class-sibling removal.
var index = $ ('. Tabs a '). Index (this),//Index
$ ('. Tab-bott '). EQ (index). Show (). siblings (). Hide ();
})
})
The above mentioned is the entire content of this article, I hope you can enjoy.