2012-09-07 21 views
1

如何在jqprint中包含外部css文件?我的代碼可能會出現什麼問題,爲什麼我不能使用內聯樣式表和等於print的介質隱藏一個簡單的按鈕?這是我的示例代碼。JQuery JQPrint css

<style type="text/css" media="print"> 

#hide 
{ 
    display:none; 
} 

</style> 

<script type="text/javascript" src="js/jquery.jqprint-0.3.js"></script> 

<script type="text/javascript"> 
    $(function() { 
     $("#printMe").click(function() { 
      $('#print').jqprint(); 

     }); 
    }); 
</script> 

<div id="header"> 
    <h1>This is the Header</h1> 
</div> 

<div id="print"><br /> 
    <input type="button" id="hide" value="hidden"/> 
    <input type="button" id="printMe" value="Print Me"/> 
</div> 

當我只使用JavaScript的window.print,它隱藏與id隱藏按鈕。可能是什麼問題呢 ?

+0

請加的jsfiddle到容易。我沒有JQPRINT插件。 – Sender

回答

0

這裏是WORKING DEMO

看到這個http://jsfiddle.net/v6K58/

$(function() { 
     $("#printMe").click(function() { 
      $('#header').jqprint(); 

     }); 
    });​ 

大膽text print

+0

當然,由於它從一開始就被隱藏,因此它會在您打印時被隱藏。我想要的是隱藏當我加載頁面時可見的元素。 – Arjel

+0

是的你可以[添加CSS看到這個](https://github.com/tanathos/jquery.jqprint/blob/master/jquery.jqprint-0.3.js)你可以[嘗試這種方式](http:// jsfiddle .net/v6K58/2 /) – Sender

+0

importCSS:true see [this](http://jsfiddle.net/v6K58/3/) – Sender