简体   繁体   English

onclick事件jquery + angular触发click事件3次

[英]onclick event jquery+angular trigger click event 3 times

I am using Jquery + Onsen UI which uses Angular. 我正在使用使用Angular的Jquery + Onsen UI。 I can't get de element event click using 我无法使用

$(element).click(function(){});

Then I am using this way 然后我用这种方式

  $(".list").on("click",".item-from-list",function(){

Ok, now it works. 好的,现在可以了。 The problem is: The list is inside an ons-carousel that has 3 slides with 3 different lists, but with the same class that I want to get click. 问题是:列表位于一个轮播中 ,该盘具有3张幻灯片,其中包含3个不同的列表,但具有我要点击的同一类。

When I click in some list item, It triggers the click event 3 times. 当我单击某个列表项时,它将触发click事件3次。 What should I do? 我该怎么办?

Thanks. 谢谢。

Have you tried looking at event.stopPropagation()? 您是否尝试过查看event.stopPropagation()?

Description : Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. 描述 :防止事件使DOM树冒泡,防止任何父处理程序收到该事件的通知。

https://api.jquery.com/event.stoppropagation/ https://api.jquery.com/event.stoppropagation/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM