Print Specific Div

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
<link rel="stylesheet" href="w3.css">
<link rel="stylesheet" href="print.css">
 <style>
 </style>
</head>
<body id="printarea">

Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit, voluptas aut fugiat at excepturi ratione architecto possimus consequuntur consequatur facere qui odit autem nisi non cumque nemo aperiam doloribus nihil.
  <div id="printarea">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt, vel. Dolorem libero in est quisquam, nesciunt repellat omnis praesentium similique veritatis neque temporibus esse eius adipisci repellendus quia laudantium cum.</div>
 <p>HOME  SNIPPETS  ADDON  WINDOW PRINT METHOD
    Window Print Method
    By JavaScriptSource Staff on Feb 23, 2006
    Add a button to allow your visitors to print your Web page. Compact and simple, yet highly requested.
    
    The JavaScript Source: Snippets : Window Print Method
    Simply click inside the window below, use your cursor to highlight the script, and copy [Control]+C the script into a new file in your text editor (such as Note Pad) and save [Control+S]. The script is yours!!! 
    </p>
  <button onclick=" printElem('a')">Print</button>
 <script>
 function printElem(divId) {
    var content = document.getElementById(divId).innerHTML;
    var mywindow = window.open('', 'Print', 'height=600,width=800');

    mywindow.document.write('<html><head><title>Print</title>');
    mywindow.document.write('</head><body >');
    mywindow.document.write(content);
    mywindow.document.write('</body></html>');

    mywindow.document.close();
    mywindow.focus()
    mywindow.print();
    mywindow.close();
    return true;
}
 </script>
     
   
</body>
</html>