Reputation: 1151
I'd like to attach the event listener on my div tag so I know if the user tap the element. How can I achieve this with or without a jQuery.
<div class="chart" id="circle_chart">test</div>
<script>
document.addEventListener('touchstart', function(event) {
alert(event.touches.length);
}, false);
</script>
Upvotes: 1
Views: 190
Reputation: 429
$("#circle_chart").bind('touchstart', function(event) {...});
Should work with jQuery, see How to bind 'touchstart' and 'click' events but not respond to both? for more on this and related issues.
Upvotes: 1