Search code examples
javascriptjqueryhtmlpluginsprintthis

How to add printThis() element exception?


is it possible to not print a div include in a printThis() element ?

example :

<div id="print-it">

<div>hello</div>

<div id="no-print-this">
<button>must be show on page but not print</button>
</div>

</div>

<button id="printMe">Print button</button>

AND JQUERY

$("#printMe").click(function () {
$('#print-it').printThis();
});
});

the div id "no-print-this" is ever show to print... is it possible to hide it on the print page with this jQuery printing plugin method ?

Can add $('#no-print-this').hide(); to the jquery click function but div "no-print-this" is not show again after closing print window browser...

The @media print method have no effect here. So i dont know if its possible with the prinThis jquery plugin.

Thanks !


Solution

  • so the solution : (thanks to Showdev)

    $("#printMe").click(function () {
    
    $('#print-it').printThis({
                importCSS: true,
                importStyle: true,
                loadCSS: "/assets/css/print_rules_page1.css"
                });
    });
    

    it need to use inportCSS and loadCSS with the printThis() jquery plugin

    CSS ("loadCSS" load file print_rules_page1.css)

    @media print 
    {
    #no-print-this,#no-print-this2 *{
    display: none !important;
    }
    }