How to print single lines in my result using window.print

enter image description here

How to print single lines in my result using window.print, only in the anchor tag that I added like this, it brings the whole line in my table, I want to print individually

+4
source share
1 answer

According to print html via javascript / jquery you can use this code:

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 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/

0
source

Source: https://habr.com/ru/post/1622215/


All Articles