简体   繁体   中英

How can I get innerhtml except one of its child Jquery

I want to print my elements so I need to get innerHtml of the whole div but I need to hide one element from printed but still found in the main page

My attempt looks like this

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;

this works fine but I need to hide the elment ID ="attach"

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

Using jQuery:

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

or

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

Try this

$('#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 */

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM