首页 > 其他 > 详细

控制元素的点击执行事件只执行一次

时间:2016-10-17 11:28:02      阅读:243      评论:0      收藏:0      [点我收藏+]
if(e.handled !== true){ }
e.handled=true;
function(e)
 
 
 
完整例子:
$(‘.shoucangtitlele‘).click(function(e){
                if(e.handled !== true){
                    var data = $(this).attr(‘data‘);
                    alert(data);
                    if(data==‘on‘){
                        $(this).children(‘b‘).html(‘已收藏‘);
                        $(this).children(‘span‘).addClass(‘shoucanghou‘);
                        $(this).children(‘span‘).html(‘<i class="fa fa-star" aria-hidden="true"></i>‘);
                        $(this).attr(‘data‘,‘off‘);
                    }
                    if(data==‘off‘){                
                        $(this).children(‘b‘).html(‘收藏‘);
                        $(this).children(‘span‘).removeClass(‘shoucanghou‘);
                        $(this).children(‘span‘).html(‘<i class="fa fa-star-o" aria-hidden="true"></i>‘);
                        $(this).attr(‘data‘,‘on‘);
                    }
                e.handled=true;
                }
            });

控制元素的点击执行事件只执行一次

原文:http://www.cnblogs.com/mm2015/p/5968806.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!