javascript用最简单的代码实现局部打印功能,下面web建站小编给大家简单介绍一下实现代码!
html代码:
<p id="print1">打印当前区域1</p> <p id="print2">打印当前区域2</p> <button onclick="printer1()">打印区域1</button> <button onclick="printer2()">打印区域2</button>
js代码:
//打印区域1
function printer1(){
  var newWin = window.open('printer', '', '');
  var print = document.getElementById("print1").innerText; //打印区域
  newWin.document.write(print);
  newWin.document.location.reload();
  newWin.print();
  newWin.close();
}
//打印区域2
function printer2(){
  var newWin = window.open('printer', '', '');
  var print = document.getElementById("print2").innerText; //打印区域
  newWin.document.write(print);
  newWin.document.location.reload();
  newWin.print();
  newWin.close();
}
jQuery实现网页div局部打印(jQuery.print插件)
上面是“js最简单的代码实现局部打印功能(非插件)”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2881.html
workflows工作流
 一个可爱的人形小机器人和一只蜗牛在森林 一个可爱的人形小机器人和一只蜗牛在森林
 雪地里一只可爱的小老虎 雪地里一只可爱的小老虎
 半透明的玻璃苹果ComfyUI工作流 半透明的玻璃苹果ComfyUI工作流
 一只被水晶包围的小动物ComfyUI工作流 一只被水晶包围的小动物ComfyUI工作流
 一群可爱的小老鼠ComfyUI工作流 一群可爱的小老鼠ComfyUI工作流
 强大的长袍法师ComfyUI工作流 强大的长袍法师ComfyUI工作流
 一条赤壁龙从蛋中孵化出来ComfyUI工作流 一条赤壁龙从蛋中孵化出来ComfyUI工作流
 星空星域星球comfyui工作流 星空星域星球comfyui工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

 日历设置每个月颜色都不一样
 日历设置每个月颜色都不一样 RTvue 低代码开发平台
 RTvue 低代码开发平台 利用css绘画棋盘布局(象棋)
 利用css绘画棋盘布局(象棋) 利用CSS3做一个星级评分样式
 利用CSS3做一个星级评分样式 原生ajax接口在线执行
 原生ajax接口在线执行 3d文字360度旋转
 3d文字360度旋转 css3动画loading效果
 css3动画loading效果 js+css3做一个灯泡开灯关灯效果
 js+css3做一个灯泡开灯关灯效果










