Trying to select what will be printed on window.print()
.
Added the outmost element, so it contains childs elements (what explains the reason of using .printable
and .printable *
), class with printable
, and added the style:
@media print{
*:not(.printable *, .printable){
display: none !important;
}
}
The window.print()
, when called, still shows everything.
EDIT 1
Tried to add notPrintable
to all :not(.printable, .printable *, .notPrintable)
with jQuery and refer notPrintable
on @media print
.
Code:
jQuery:
$(":not(.printable, .printable *, .notPrintable)").addClass("notPrintable");
CSS:
@media print{
.notPrintable{
display: none !important;
}
}
Now nothing shows.
EDIT 2
Putting the solution example here if anyone needs it (available only after having an answer marked as accepted):