I am trying to only print certain elements with JavaScript. For example, when a link is clicked it will open the print dialog window. However, I wish to have some elements of the table not printed and for the headers to be on one line instead of breaking into multiple lines.
I want to get rid of the Edit and Delete table cells and put all the table headers on one line. Here is my current JavaScript code I have in place:
$('#print').on('click', function() {
var content = document.getElementById("sample_editable_2");
var holderWindow = window.open("");
holderWindow.document.write(content.outerHTML);
holderWindow.print();
holderWindow.close();
});
Sorry if this is unclear, I've never attempted this before.
Appreciate any help that can be given.
- Edit:
Here is my css file
@media print {
.h_edit {
display: none;
}
.h_delete {
display: none;
}
.b_edit {
display: none;
}
.b_delete {
display: none;
}
.order-issue {
white-space: nowrap;
}
.sub-shipping-issue {
white-space: nowrap;
}
.sub-refunds-returns-issue {
white-space: nowrap;
}
.sub-update-issues {
white-space: nowrap;
}
.sub-campaign-issues {
white-space: nowrap;
}
.sub-campaign-change-issues {
white-space: nowrap;
}
.sub-campaign-design-issues {
white-space: nowrap;
}
.sub-teeforall-works {
white-space: nowrap;
}
.order-id {
white-space: nowrap;
}
.site-url {
white-space: nowrap;
}
}
and I am calling the css file like so: <link rel="stylesheet" media="print" type="text/css" href="/css/print.css">
but it is still not hiding the elements and making them not wrap.