html中刪除表格一行其實很簡單,但是加上一個提示彈窗后,點擊確定后卻獲取不到要刪除的是哪一行,下面是一個demo
html:
<tr> <td> <input type="checkbox" class="checkBig" /> </td> <td>安徽車樂優</td> <td>13888888888</td> <td>安徽省合肥市政務區金寨路與潛山路交口金潛廣場</td> <td>門店</td> <td> <div class="opo"> <div class="modify">修改</div> <div class="delete" onclick="shanchu(this)">刪除</div> </div> </td> </tr>
彈窗:
<!--刪除--> <div class="delcon"> <div class="desure">確認刪除?</div> <div class="delfoot"> <div class="delcer">確認</div> <div class="delcan">取消</div> </div> </div>
彈窗css:
.delcon{ width: 30%; overflow: hidden; background: #fff; box-sizing: border-box; border: 5px solid #3eb4c5; position: fixed; left: 33%; top: 20%; z-index: 999; display: none; } .desure{ width: 100%; height: 35px; line-height: 35px; text-align: center; margin-top:45px; margin-bottom: 30px; } .delfoot{ width: 100%; height: 35px; margin-bottom: 20px; } .delcer{ float: left; margin-left: 20%; width: 80px; height: 35px; line-height: 35px; text-align: center; color: #fff; font-size: 12px; font-weight: 700; background: #3eb4c5; cursor: pointer; } .delcan{ float: left; margin-left: 15%; width: 80px; height: 35px; line-height: 35px; text-align: center; color: #383838; font-size: 12px; /*font-weight: 700;*/ box-sizing: border-box; border:1px solid #C3C3C3 /*background: #3eb4c5;*/; cursor: pointer; }
js;
//刪除 function shanchu (obj){ $('.delcon').fadeIn() // //確定 $('.delcer').click(function(event){ $(obj).parent().parent().parent().remove(); $('.delcon').fadeOut() }) //取消 $('.delcan').click(function(event){ $('.delcon').fadeOut() }) }