点击删除内容
例表在编辑一个图片列表的时候,我面需要删除其中的一张图片,我们则可以通过 Jremove()来实现
例子如下:
<tr> <td class="">酒店图片</td> <td> <input class="form_submit" onclick="upImage()" value="上传多图" type="button"> <div class="showimg"> <li> <img src="/Public/Upload/image/20160920/1474343910457858.jpg"> <p class="delete_img">删除</p> <input name="showimg[]" value="/Public/Upload/image/20160920/1474343910457858.jpg" type="hidden"> </li> <li> <img src="/Public/Upload/image/20160913/1473732340426293.jpg"> <p class="delete_img">删除</p> <input name="showimg[]" value="/Public/Upload/image/20160913/1473732340426293.jpg" type="hidden"> </li> <li> <img src="/Public/Upload/image/20160901/1472697334474908.jpg"> <p class="delete_img">删除</p> <input name="showimg[]" value="/Public/Upload/image/20160901/1472697334474908.jpg" type="hidden"> </li> <li> <img src="/Public/Upload/image/20160901/1472697301140100.jpg"> <p class="delete_img">删除</p> <input name="showimg[]" value="/Public/Upload/image/20160901/1472697301140100.jpg" type="hidden"> </li>
</div> </td> </tr>
我们需要点击删除则删除当前LI下的图片及input 也就是我们直接删除当前的LI就可以完成了
<script> $(function(){ $('.delete_img').live('click',function(){ $(this).parent().remove(); }); }); </script>