我怎样才能得到 innerhtml,除了它的子 Jquery 之一

How can I get innerhtml except one of its child Jquery

本文关键字:之一 Jquery innerhtml      更新时间:2023-09-26

我想打印我的元素,所以我需要获取整个div的innerHtml,但我需要从打印中隐藏一个元素,但仍在主页中找到

我的尝试看起来像这样

var printcontent = document.getElementById(el).innerHTML
             +" <div class='row'><span class='glyphicon glyphicon-tasks'></span><b></b></div>"
             + document.getElementById(tble).innerHTML
             + document.getElementById(img).innerHTML;

这工作正常,但我需要隐藏 elment ID ="附加"

var panel = document.getElementById(el).innerHTML;
var filteredpanel = panel.remove(document.getElementById("attach").innerHTML)

使用 jQuery:

$('#divID').not('#attach');

$('#divID:not(#attach)');

试试这个

$('#attach').hide(); /* hide */
var printcontent = $(el).html() /* assign var */
             +" <div class='row'><span class='glyphicon glyphicon-tasks'></span><b></b></div>"
             + $(tble).html()
             + $(img).html();
$('#attach').show(); /* show again */