2011-03-18 88 views
0

如何我只是使用jQuery打印我的網頁上的文章一個div,文章是一個div裏面 window.print()將打印整個窗口。 所以很少和那個混淆......!打印使用jQuery

回答

5

不要使用jQuery ...使用css和media = print。這是一個article for referencehere

基本上,創造你想,當你打印顯示什麼新的樣式表,和媒體設置打印:使用不同的樣式表通常實現打印

<link rel="stylesheet" type"text/css" href="print.css" media="print"> 
1

造型HTML,例如在你的腦袋元素:

<head> 
    ... 

    <link rel="stylesheet" type="text/css" media="screen" href="style.css"> 
    <link rel="stylesheet" type="text/css" media="print" href="print.css"> 
    ... 

</head> 

樣式表的style.css用來風格你在屏幕上的HTML,而print.css用於你的樣式打印HTML。通過在print.css中提供適當的樣式,您可以輕鬆地顯示或隱藏html元素以實現您要查找的輸出。