qq_39129404 2017-08-03 03:32 采纳率: 100%
浏览 2575
已采纳

两重DIV里面怎么在嵌套的DIV里面点击一个按钮后删除当前div

图片说明

 <div class="weui-form-preview" style="margin-top:10px" id="d1">
    <div class="weui-form-preview__bd" style="text-align:right;margin-right:50px">
    <a id="show-delete" href="javascript:;" style="position:absolute;margin-top:20px;width:40px;color:#199ED8;font-size:18px;">作废</a>
    <div class="weui-form-preview__item">
      <label class="weui-form-preview__label" style="color:#666666">购货方名称:</label>
      <span class="weui-form-preview__value" style="text-align:left;color:#666666">海南省海口市XXX有限公司</span>
    </div>
    <div class="weui-form-preview__item">
      <label class="weui-form-preview__label" style="color:#666666">金额:</label>
      <span class="weui-form-preview__value" style="text-align:left;color:#666666">1000.0元</span>
    </div>
    <div class="weui-form-preview__item">
      <label class="weui-form-preview__label" style="font-size:10px">申请日期:</label>
      <span class="weui-form-preview__value" style="text-align:left;font-size:10px">2017-01-01</span>
    </div>
    </div>
  </div>

  <div class="weui-form-preview" style="margin-top:20px">
    <div class="weui-form-preview__bd" style="text-align:right;margin-right:50px">
    <a id="show-delete" href="javascript:;" style="position:absolute;margin-top:20px;width:40px;color:#199ED8;font-size:18px">作废</a>
    <div class="weui-form-preview__item">
      <label class="weui-form-preview__label" style="color:#666666">购货方名称:</label>
      <span class="weui-form-preview__value" style="text-align:left;color:#666666">海南省海口市XXX有限公司</span>
    </div>
    <div class="weui-form-preview__item">
      <label class="weui-form-preview__label" style="color:#666666">金额:</label>
      <span class="weui-form-preview__value" style="text-align:left;color:#666666">1000.0元</span>
    </div>
    <div class="weui-form-preview__item">
      <label class="weui-form-preview__label" style="font-size:10px">申请日期:</label>
      <span class="weui-form-preview__value" style="text-align:left;font-size:10px">2017-01-01</span>
    </div>
    </div>
  </div>

  <div class="weui-form-preview" style="margin-top:20px">
    <div class="weui-form-preview__bd" style="text-align:right;margin-right:50px">
    <a id="show-delete" href="javascript:;" style="position:absolute;margin-top:20px;width:40px;color:#199ED8;font-size:18px">作废</a>
    <div class="weui-form-preview__item">
      <label class="weui-form-preview__label" style="color:#666666">购货方名称:</label>
      <span class="weui-form-preview__value" style="text-align:left;color:#666666">海南省海口市XXX有限公司</span>
    </div>
    <div class="weui-form-preview__item">
      <label class="weui-form-preview__label" style="color:#666666">金额:</label>
      <span class="weui-form-preview__value" style="text-align:left;color:#666666">1000.0元</span>
    </div>
    <div class="weui-form-preview__item">
      <label class="weui-form-preview__label" style="font-size:10px">申请日期:</label>
      <span class="weui-form-preview__value" style="text-align:left;font-size:10px">2017-01-01</span>
    </div>
    </div>
  </div>

用了这种还是一样不行啊
图片说明

 function deleteRegist(buttons){
     var $f = $(buttons);
     var $parent = $f.parent("div");
     $parent.empty();


}
  • 写回答

8条回答 默认 最新

  • 苏小苏 2017-08-03 06:17
    关注

    $(document).on("click", "#show-delete", function () {
    var $parent = $(this).parent();
    $.confirm({
    //这里不变,都是一样
    //然后将deleteRegist(this)直接换成 $($parent).remove();
    })
    })
    页面中id只能出现一次,你这个按钮id=show-delete最好改成class=show-delete

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(7条)

报告相同问题?

悬赏问题

  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 android报错 brut.common.BrutException: could not exec (exit code = 1)
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!