WEB/jQuery
특정 div 프린트 하기
remoted
2018. 5. 11. 18:48
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]