js window.print实现打印特定控件或内容

window.print可以打印网页,但有时候我们只希望打印特定控件或内容,怎么办呢?

window.print打印指定div
首先我们可以把要打印的内容放在div中,然后用下面的代码进行打印。
复制代码 代码如下:




div print



//HTML Page
//Other content you wouldn't like to print




The Div content which you want to print




//Other content you wouldn't like to print
//Other content you wouldn't like to print


你可能感兴趣的:(js window.print实现打印特定控件或内容)