js打印代码
作者:小编
更新时间:2023-10-16
点击数:
按钮代码: onclick="printme();" JS代码: <script type="text/javascript"> function printme(){ let newstr = document.getElementById("div1").innerHTML; //div1为要打印的内容 let oldstr = document.body.innerHTML; document.body.innerHTML = newstr; window.print(); document.body.innerHTML = oldstr; return false; } </script> 打印代码封闭DIV: <div id="div1">需要打印的内容</div>