删除< div>使用jQuery [英] Remove <div> using jQuery

查看:67
本文介绍了删除< div>使用jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个HTML代码:

I have this HTML code:

<div id="note_list">
  <div class="note">
    Text 1
    <a href="">X</a>
  </div>
  <div class="note">
    Text 2  
    <a href="">X</a>
  </div>
  <div class="note">
    Text 3  
    <a href="">X</a>
  </div>
  <div class="note">
    Text 4  
    <a href="">X</a>
  </div>
  <div class="note">
    Text 5  
    <a href="">X</a>
  </div>  
</div>

现在我想用jQuery来删除一个< div> 元素'X'点击后,是否可以?

Now I would like to use jQuery to delete a <div> element AFTER the 'X' clicking, is it possible?

第一个X关闭:

  <div class="note">
    Text 1
    <a href="">X</a>
  </div>

等等。
我可以删除 div 而不使用 id =

谢谢!

推荐答案

$(".note a").click(function(e) {
    e.preventDefault();
    $(this).parent().remove();
});

或代替 remove()你可以使用 slideUp()

这篇关于删除&lt; div&gt;使用jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆