These days to do the project, found that mobile needs to touch the event, and click must not be, so I have the Tap event encapsulation Search, found an article, the original address is as follows: Http://www.jb51.net/article/50663.htm,
I add something to the first package, wrap it in a function, call it directly when you use it, and the source code is as follows (Tap.js):
function tap (Ele, fn) { var starttx, Startty; var endtx, Endty; Ele.addeventlistener (' Touchstart ', function (e) { var touches = e.touches[0]; Starttx = Touches.clientx; Startty = Touches.clienty;}, False); Ele.addeventlistener (' Touchend ', function (e) { var touches = e.changedtouches[ 0], endtx = Touches.clientx, endty = Touches.clienty; if (Math.Abs (STARTTX-ENDTX) < 6 && Math.Abs (STARTTY-ENDTY) < 6) { fn (); }}, False);}
Using the method, introduce the JS file (i.e. tap.js) and execute the following call:
/* parameter Description: ele: Native DOM object fn: Callback method, perform the action you need */tap (Ele,function () { //action you need to perform});
JS Mobile-tap Event encapsulation