yaragallamurali Posted September 23, 2013 Share Posted September 23, 2013 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 More sharing options...
harpalsinh999 Posted September 23, 2013 Share Posted September 23, 2013 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 More sharing options...
yaragallamurali Posted September 23, 2013 Author Share Posted September 23, 2013 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 More sharing options...
davej Posted September 23, 2013 Share Posted September 23, 2013 I would think about creating a new window with just the desired div innerHTML and a print button. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now