I had a use case recently where I need to determine whether the client browser was a desktop/laptop/etc or a mobile device that supports tap events in JS. This will be useful to people who are dynamically binding different events to elements.
1 2 3 |
var tmpElem = document.createElement('div'); tmpElem.setAttribute('tap', 'return;'); clickEvent = (typeof tmpElem.tap == "undefined") ? 'click' : 'tap' ; |
You would use it like this
1 2 3 4 5 |
$('.showDetails').bind(clickEvent,function(e){ display(e, $(this).attr('info')); console.log( clickEvent + " " + $(this).attr('info')); //would look like "Click fooBar" }); |
No Comments
You can leave the first : )