我有像这样的HTML行
<div class="wsdRow">
<div class="ib swsLbl">(new)</div>
<div class="ib swsLbl"><input type="text" class="wsd"></div>
<div class="ib swsLbl"><input type="text" class="wsAmount numbersOnly"></div>
<div class="ib swsLbl">
<button class="saveWC">save</button>
<button class="delWC">-</button>
<div class="wcResult ib"></div>
</div>
<div class="clr"></div>
</div>
<div class="wsdRow">
<div class="ib swsLbl">(new)</div>
<div class="ib swsLbl"><input type="text" class="wsd"></div>
<div class="ib swsLbl"><input type="text" class="wsAmount numbersOnly"></div>
<div class="ib swsLbl">
<button class="saveWC">save</button>
<button class="delWC">-</button>
<div class="wcResult ib"></div>
</div>
<div class="clr"></div>
</div>
然后我像这样绑定删除按钮
$(".delWC").click(function(){
var ths=$(this).parent().parent(".wsdRow");
alertify.confirm("are you sure you want to delete this row?", function (e) {
if (e) {
$(ths).remove();
}
});
});
出于某种原因,我必须两次点击alertify.confirm。用户第一次单击“确定”时,行将按预期删除,但警报会一直保持到再次单击为止。如果他们点击“取消”,他们仍然需要做两次,否则它不会消失。
答案 0 :(得分:1)
尝试使用此
$('[id^=alertify]').remove();