Zepto. js, zepto. jstap
The example in this article describes how the tap event in zepto. js blocks bubbles. Share it with you for your reference. The details are as follows:
Recently, I was working on a Mobile website that wanted to use jQuery Mobile, but the file was too large, so I used zepto. js.
Because the use of the click Event in mobile Web pages has a delay, the tap event in zepto. js is used.
You can use stopPropagation to prevent bubbling by using the click event, but this method is not valid for the tap.
Now I need to achieve this effect: Click the. btn button and display div. panel. When I click non-div. panel, hide div. panel.
$ (". Btn "). on ("tap", function (e) {e. stopPropagation (); // This method does not work $ ("div. panel "). show () ;}); $ (document ). on ("tap", function (e) {$ ("div. panel "). hide ();});
Through the debugging tool, we can get that the object e has a target attribute, so we can use this attribute to achieve the desired effect:
$ (". Btn "). on ("tap", function () {$ ("div. panel "). show () ;}); $ (document ). on ("tap", function (e) {if (! Certificate (e.tar get). hasClass ("btn") {$ ("div. panel"). hide ();}});
This solves the problem.
I hope this article will help you design javascript programs.