The unbinding pop-up window is public. When I click confirm and cancel, how do I know that the corresponding bank card click is the unbinding (corresponding bank card dom removal) operation
建设银行
储蓄卡
**** **** ****
解绑 建设银行
储蓄卡
**** **** ****
解绑 建设银行
储蓄卡
**** **** ****
解绑 确定解绑该银行卡吗?
取消 确认
建设银行
储蓄卡
**** **** ****
解绑 建设银行
储蓄卡
**** **** ****
解绑 建设银行
储蓄卡
**** **** ****
解绑 确定解绑该银行卡吗?
取消 确认
用 jquery 的 方式 $('.ubind-card').click(function(){ //的到当前银行卡列表的下标 var ubindIndex = $(this).parents('.bankcard-block').index(); //给确定按钮赋一个标识 $('.unbind-sure').attr('val',ubindIndex ).show(); }); $('.unbind-sure').click(function(){ var index = $(this).attr('val'); $('.bankcard-block:eq('+index+')').remove(); });
. When the user clicks to confirm, you can just go to the top to get it.
Get the
DOMJavaScript event object
event.target
orevent.currentTarget
Use a variable to save the currently operated card.
<code class="javascript">var currentCart = -1;//默认-1 $('#cards').on('click','.btnJieBang',function(){ currentCart=this.dataset.cartid; }); //弹窗确定的事件里,去读取currentCart变量即可</code>
When you click Unbind, you can get its parent element, and then delete the parent element through related operations to achieve the goal.
Add a distinguishable data-id after unbinding
Bind a unique identifier