您的位置:首页 > Web前端 > JQuery

jquery.mobile.js tap事件执行两次

2018-03-06 09:52 253 查看
今天做一个点击选中,再次点击取消选中的功能,但是发现偶尔会点击一下tap方法却执行了两次,搞得我头疼,调了半天bug没找到原因,最后加了一个return false发现好了,可能是事件冒泡的问题。$(".list-group").on("tap","li",function(event){
event.stopPropagation();
var length = $(this).find(".glyphicon").length;
if (length>0){//选中状态下
$(this).removeClass("choose");
$(this).find(".glyphicon").remove();
}else {
$(this).addClass("choose");
$(this).find("span:eq(0)").after('<span class="glyphicon glyphicon-ok-circle" aria-hidden="true" style="font-size: 1.1em;color: #f3cc0c"></span>')
}
return false;
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: