spicykimchi
spicykimchi

Reputation: 1151

Attached the document.addEventListener on my element

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

Answers (1)

Henrik M&#252;he
Henrik M&#252;he

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

Related Questions