Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

226
Views
How to print specific div WITH its css applied

I have created a button that when you click it, it will open up a window to print a specific div (the todos div).

See images bellow:

  1. The initial project The initial project.

  2. What do I see when I click the print buttonenter image description here

As you can see when I click the print button, it displays only the the todos without the applied css. How can I do this?

JS for print button:

<script type="text/javascript">
    function printDiv(divName) {
        var printContents = document.getElementById(divName).innerHTML;
        w=window.open();
        w.document.write(printContents);
        w.print();
        w.close();   
    }
</script>

HTML for the print button:

<input type="button" id="print-btn" onclick="printDiv('printArea')" value="print a div!"/>
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!