MGLP Posted December 16, 2018 Share Posted December 16, 2018 I have buttons on a page which I don't want to come out on a print. My " class='noprint' " in my following code doesn't work. <input type='Button' value='Print' class='noprint' onclick='printpage()'> Tks Link to comment Share on other sites More sharing options...
dsonesuk Posted December 16, 2018 Share Posted December 16, 2018 You would use media query for printing devices to control layout, what is or not printed https://www.w3schools.com/cssref/tryit.asp?filename=trycss3_media Link to comment Share on other sites More sharing options...
JMRKER Posted December 21, 2018 Share Posted December 21, 2018 Example of how it might be done. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title> Screen / Print Displays </title> <style> @media only screen { body { color: green; } #prnButton { display: inline; } } @media only print { body { color: black; } #prnButton { display: none; } } </style> </head> <body> <h1>The @media Rule</h1> <p>Use mediaqueries to set the text color to green <br>when the document is displayed on the screen, and to black when it is printed.</p> <input id="prnButton" type='Button' value='Print' onclick='printpage()'> </body> <script> function printpage() { window.print(); // logic to print the page } </script> </html> 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