dr6673999 2011-10-06 22:07
浏览 4
已采纳

如何构建jQuery删除

I have some like that.

<script src="http://code.jquery.com/jquery-latest.js"></script>
<table>
<tr title="test" id="ex1">
    <td><div class="move">Hello</div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
</tr>
<tr id="ex2">   
    <td><div class="move">Hello</div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
</tr>       
</table>

<button>Move</button>
<script>
$("button").click(function () {
    $(".move").remove();   
    });
</script>

If I press button, the both div's will moved. But I need to move only one, according to id of tr it laid.

I have only wrong ideas:

$(".move").parent.parent.attr('id', 'ex2').remove();

Thank you so much!

  • 写回答

4条回答 默认 最新

  • dqcz57269 2011-10-06 22:10
    关注

    That would be

    $("#ex2 .move").remove();
    

    Simple ya? remember that jQuery selectors are the same as CSS selectors.

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

报告相同问题?

悬赏问题

  • ¥15 vue3加ant-design-vue无法渲染出页面
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序