javascript - 如何使用 window.print 在我的结果中打印单行

标签 javascript php

enter image description here

如何使用 window.print 在我的结果中打印单独的行,就像我添加的 anchor 标记一样打印,它带来了我想要以单独方式打印的表格中的所有行

最佳答案

根据 print html through javascript / jquery你可以使用这段代码:

function Print() {
  var docprint = window.open("about:blank", "_blank");//new page
  var oTable = document.getElementById("result_tbl").rows.item(0); //get the 1st row by a selector
  docprint.document.open();
  docprint.document.write('<html><head><title>Ashley Mattresses</title>'); //write HEAD section
  docprint.document.write('</head><body><center>'); //write BODY tag and center tag for printing
  docprint.document.write(oTable.innerHTML); //select the TR's HTML and add it to the new page
  docprint.document.write('</center></body></html>'); //close BODY tag
  docprint.document.close();
  docprint.print();
  docprint.close();
}

http://jsfiddle.net/v7CNG/77/

关于javascript - 如何使用 window.print 在我的结果中打印单行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34530386/

相关文章:

javascript - 当 $scope 更改时重新运行响应式(Reactive)助手

javascript - Bootstrap 3 工具提示不起作用

javascript - 无法捕获通过 Jquery Ajax 发送的 $_POST/$_GET

php - Laravel 数据库日志 - 什么是最佳实践

javascript - 如何通过Ajax向Mysql插入多标签输入同名

Javascript 函数不返回数据 - Node-MySQL

JavaScript - 特殊的多重继承

php - 使用codeigniter将动态添加的表中的多个数据插入数据库

php - 用php回显mysql查询结果

javascript - 在 SPA 中创建干净的 ID 空间的常见解决方案是什么?