在我的元素上附加了document.addEventListener

时间:2012-10-02 11:31:29

标签: javascript-events

我想在我的div标签上附加事件监听器,以便我知道用户是否点击了该元素。如何使用或不使用jquery来实现此目的。

<div class="chart" id="circle_chart">test</div>

<script>
    document.addEventListener('touchstart', function(event) {
        alert(event.touches.length);
    }, false);
</script>

1 个答案:

答案 0 :(得分:1)

$("#circle_chart").bind('touchstart', function(event) {...});

应该使用 jQuery,有关此问题及相关问题的详情,请参阅How to bind 'touchstart' and 'click' events but not respond to both?

相关问题