×

Welcome to TagMyCode

Please login or create account to add a snippet.
1
0
 
0
Language: Javascript
Posted by: Jesse Tinell
Added: Jan 30, 2013 8:41 PM
Modified: Feb 1, 2013 12:41 PM
Views: 41
This is about 300ms faster.
  1. var browserEvent;
  2. if ("ontouchstart" in document.documentElement)
  3. {
  4.     browserEvent = "touchstart";
  5. }
  6. else
  7. {
  8.     browserEvent = "click";
  9. }
  10.  
  11. $("#someDiv").bind(browserEvent, function (e)
  12. {
  13.     //Do stuff
  14. });