Jump to content

how to printing a particular div?


yaragallamurali

Recommended Posts

Hi I have 5 div tags in my html page and there is a print button. when i click on the print button it has to print only a particular div. for example it has to print the 2nd div which contains some personal information. It should not print the rest of the page. Only the content of the 2nd div should be printed. how to achieve this?

Link to comment
Share on other sites

You could use a print specific CSS stylesheet and hide everything but what you want printed.

 

<div class="no-print">I won't print</div><div class="something-else">I will!</div>

 

 

Just the no-print class will be hidden, but anything with a print class will show.

 

<style type="text/css" media="print">.no-print { display: none; }</style>
Link to comment
Share on other sites

there is a problem. if display=none then the div's are not visible in the browser. I don't want this to happen. Even when everything is being displayed only a particular div should get printed. My most concern is the view in the browser should not change because of printing. Is there any good solution for this?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...