css:

@media print {
    body * {
        visibility: hidden;
    }
    #section-to-print,
    #section-to-print * {
        visibility: visible;
    }
    #section-to-print {
        position: absolute;
        left: 0;
        top: 0;
    }
    .section-not-to-print {
        display: none;
    }
}

html:

 <div id="section-to-print">
       打印区域
      <div class="section-not-to-print> 打印区域不希望被打印的部分 </div>
 </div>

通过 window.print() 打印

<input type="button" onclick="window.print" value="print a div!" />