解决方法:加off解除委托的事件 $('.producttable tbody').on('click','tr',function(){ if ($(this).hasClass('rchecked')){ $(this).removeClass( 'rchecked').find('input').prop('checked', false); } else { $(this).closest('tbody').find('tr').not($(this).index()).removeClass('rchecked'); $(this).addClass('rchecked').find('input').prop("checked", true); } }) $('.producttable tbody').off('click','tr').on('click','tr',function(){ //debugger //alert('产品点击事件') if ($(this).hasClass('rchecked')){ $(this).removeClass( 'rchecked').find('input').prop('checked', false); } else { $(this).closest('tbody').find('tr').not($(this).index()).removeClass('rchecked'); $(this).addClass('rchecked').find('input').prop("checked", true); } })
onclick监听事件点击一次触发多次问题
最新推荐文章于 2024-02-08 22:36:05 发布