jQuery Print function to print div content with css

前端 未结 4 958
难免孤独
难免孤独 2020-12-31 09:38

I\'ve this function for my Wordpress plugin uses jQuery that prints the content from the div with class \"table_disp\". How can I print the css style along with it.

4条回答
  •  鱼传尺愫
    2020-12-31 09:50

    function PrintElem(elem) {
        Popup(jQuery(elem).html());
    }
    
    function Popup(data) {
        var mywindow = window.open('', 'my div', 'height=400,width=600');
        mywindow.document.write('');
        mywindow.document.write('');  
        mywindow.document.write('');
        mywindow.document.write(data);
        mywindow.document.write('');
        mywindow.document.close();
        mywindow.print();                        
    }
    
    Print
    

提交回复
热议问题