第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Jquery中click事件重復(fù)執(zhí)行的問題

Jquery中click事件重復(fù)執(zhí)行的問題

慕妹3242003 2019-04-09 20:25:34
Jquery版本1.11.0問題:點(diǎn)擊修改鏈接,在彈出的對話框中,點(diǎn)提交按鈕,click事件會執(zhí)行多次。而用原生js則沒有問題。并且提交后,第二次提交后,多個數(shù)據(jù)都變成一個了。代碼如下:點(diǎn)擊了多少次修改,點(diǎn)提交時就會alert出多少個222222http://jsfiddle.net/D7eEd/出問題部分用原生js實(shí)現(xiàn):http://jsfiddle.net/vowmmm/n5yzy/個人認(rèn)為原因是:click事件里不能包含click事件?不知道是不是這樣。為方便查看,附帶整個文檔Document*{margin:0;padding:0;}#table{border:1pxsolidgray;border-collapse:collapse;width:500px;}tr{height:30px;}th{border:1pxsolidgray;}td{border:1pxsolidgray;text-align:center;}tda{margin-right:5px;color:blue;text-decoration:none;}#popDiv,#editDiv{border:1pxsolidsilver;width:315px;padding:1px;margin-top:10px;position:absolute;left:38%;z-index:4;display:none;}.popp{height:30px;margin-top:20px;clear:both;}.popa{display:block;float:right;text-decoration:none;font-size:12px;}.pop.input{height:20px;line-height:20px;}/*#bottom{width:100%;height:30px;margin:0auto;}*/#sub{display:block;height:30px;margin:0auto;}.mask{background-color:#000;position:absolute;left:0;top:0;z-index:2;}姓名年齡職位工資操作張三23PHP79999修改李四21Java12000修改王五34Python29999修改趙六37Javascript65450修改close姓名:年齡:職位:工資://點(diǎn)擊'修改'鏈接$('a.edit').click(function(){vararr=[];$(this).parent().siblings().each(function(){arr.push($(this).text());});$('#editDiv').show().find('p').each(function(i){$(this).find('input:text').val(arr[i]);});varaTr=$(this);$('#sub').click(function(){alert('2222222');vardata=[];$(this).prevUntil('a.close').each(function(){data.push($(this).find('input:text').val());});data.reverse();aTr.parent().siblings().each(function(i){$(this).text(data[i]);});$(this).parent().hide();$('div.mask').remove();});//原生JS實(shí)現(xiàn)點(diǎn)擊,沒有問題/*document.getElementById('sub').onclick=function(){alert('1111111');vardata=[];$(this).prevUntil('a.close').each(function(){data.push($(this).find('input:text').val());});data.reverse();aTr.parent().siblings().each(function(i){$(this).text(data[i]);});$(this).parent().hide();$('div.mask').remove();};*///添加遮罩層varmaskHeight=$(document).height();varmaskWidth=$(document).width();$('').appendTo($('body'));$('div.mask').css({'width':maskWidth,'height':maskHeight,'opacity':0.4});});$('a.close').click(function(){$(this).parent().hide();$('div.mask').remove();});
查看完整描述

2 回答

?
吃雞游戲

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個贊

已經(jīng)找到原因了,我提供個方法吧:
$('#sub').unbind('click').click(function(){
...
});
每次綁定前先取消上次的綁定。
                            
查看完整回答
反對 回復(fù) 2019-04-09
  • 2 回答
  • 0 關(guān)注
  • 366 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號