Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

print a specific div in javascript

function PrintElem(elem) {
    const mywindow = window.open('', 'PRINT', 'height=400,width=600');

    mywindow.document.write('<html><head><title>' + document.title  + '</title>');
    mywindow.document.write('</head><body >');
    mywindow.document.write('<h1>' + document.title  + '</h1>');
    mywindow.document.write(document.getElementById(elem).innerHTML);
    mywindow.document.write('</body></html>');
    mywindow.document.close(); // necessary for IE >= 10
    mywindow.focus(); // necessary for IE >= 10*/
    mywindow.print();
    mywindow.close();
    return true;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript regex wrap string 
Javascript :: javascript lerp 
Javascript :: check if element is array javascript 
Javascript :: react hot toast 
Javascript :: external linking of JavaScript in html 
Javascript :: form serialize to json 
Javascript :: javascript sort by id 
Javascript :: split integer into digits javascript 
Javascript :: regular expression number from 1 to 100 
Javascript :: css 2 components side by side react 
Javascript :: mouseevent clientx javascript 
Javascript :: delete attribute javascript 
Javascript :: sum of all numbers in an array javascript 
Javascript :: remove item from localstorage 
Javascript :: border bootstrap 
Javascript :: find difference in array of objects javascript 
Javascript :: react-native init AwesomeProject change port 
Javascript :: jest mongoose multiple connections 
Javascript :: how to import jquery file in react js 
Javascript :: check if mobile view javascript 
Javascript :: check if input is required jquery 
Javascript :: To set the text of button using Jquery 
Javascript :: javascript json upload 
Javascript :: lip. dips *dipped. also mm bpi. -opp. -ditty 
Javascript :: loop json jquery 
Javascript :: javascript function that make a choice 
Javascript :: stateprovider.js react 
Javascript :: react router Link does work 
Javascript :: getServerSideProps cookie 
Javascript :: how to check if a string is correctly encoded as base64 in javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =