728x90
function content_print(){ var initBody = document.body.innerHTML; window.onbeforeprint = function(){ document.body.innerHTML = document.getElementById('선택될 div id').innerHTML; } window.onafterprint = function(){ document.body.innerHTML = initBody; } window.print(); } ===============================================================================================<div id="content"> 내용 content_1</div><div id="content_2"> 내용 content_2</div><input type="button" value="print" onclick="javascript:content_print();">================================================================================================선택될 div id 이부분에 div id 를 삽입하면 된다.print 버튼을 누르면 지정된 div 안의 내용이 프린트 된다.
출처: http://mkwilson.tistory.com/64 [wilson's story]
출처: http://mkwilson.tistory.com/64 [wilson's story]
출처: http://mkwilson.tistory.com/64 [wilson's story]
출처: http://mkwilson.tistory.com/64 [wilson's story]
'WEB > jQuery' 카테고리의 다른 글
| jQuery scroll to element (0) | 2019.05.20 |
|---|---|
| jQuery API 정복 - 자식 요소들 찾기, children() (0) | 2018.05.21 |
| Returning JSON data using jQuery POST function from server (0) | 2018.05.10 |
| jQuery.getScript, JavaScript 파일을 로드하고 실행 (0) | 2018.04.19 |
| Refresh Part of Page (div) (0) | 2018.04.13 |