Prevent Instant Click Event On Touch Devices - jQuery prevent-touch
File Size: | 4.56 KB |
---|---|
Views Total: | 1146 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
prevent-touch is a lightweight yet sometimes useful jQuery plugin which prevents default tap/click events on specific touch-enabled devices using jQuery event.preventDefault() method. Great for CSS styled dropdowns/hover states.
Mobile devices supported:
- iOS
- iPhone
- iPad
- iPod
- Android
- Blackberry
- Windows
- Opera
- Any
Installation:
# NPM $ npm install prevent-touch --save
How to use it:
1. Insert the jQuery prevent-touch plugin's script after loading jQuery JavaScript library.
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="prevent-touch.js"> </script>
2. Enable the plugin on the target element(s) and specify the device(s) on which you want to prevent the default click/tap event.
$(document).ready(function(){ $('.element').preventTouch({ ios : true, iphone : true, iPad : true, iPod : true, android : true, blackBerry : true, opera : true, windows : true, any : true }); });
This awesome jQuery plugin is developed by dj10dj100. For more Advanced Usages, please check the demo page or visit the official website.