1

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>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
spicykimchi
  • 1,151
  • 5
  • 22
  • 41

1 Answers1

1
$("#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.

Community
  • 1
  • 1
Henrik Mühe
  • 419
  • 3
  • 24