簡體   English   中英

除了它的一個子 Jquery 之外,我怎樣才能獲得innerhtml

[英]How can I get innerhtml except one of its child Jquery

我想打印我的元素,所以我需要獲取整個 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 ="attach"

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 */

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM