【问题标题】:Jquery removing element from htmlJquery从html中删除元素
【发布时间】:2015-10-13 19:32:43
【问题描述】:

我有这个 html var content = $("#directions-panel > .adp").find("div[jsinstance='"+i+"']").prop('outerHTML');

我正在尝试删除 html 中的第一个表格列。

这是我的尝试,但没有奏效。

content.findr(".adp-directions > tbody > tr > td.adp-substep:eq(0)").remove();

【问题讨论】:

  • 试试$(content).find().remove();(用jQuery的选择器包裹content)。
  • 请提供示例 HTML,它将帮助人们为您提供工作和更准确的代码。
  • 放html代码或者创建jsfiddle。

标签: jquery dom html-table


【解决方案1】:

您的代码只会删除您的第一个具有adp-substep 类的单元格。 而不是你在做什么,尝试:

content.find(".adp-directions > tbody > tr").each(function(){
  jQuery(this).find("> td.adp-substep:eq(0)").detach(); //or remove
});

上面的代码将删除每个表格行的第一个单元格。

【讨论】:

    猜你喜欢
    • 2011-01-04
    • 1970-01-01
    • 1970-01-01
    • 2018-01-17
    • 2014-09-01
    • 2021-10-02
    • 1970-01-01
    • 2015-12-15
    • 1970-01-01
    相关资源
    最近更新 更多