

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set the page-break behavior after an element with JavaScript?
Use the pageBreakAfter property in JavaScript to set the page-break behavior after an element. Use the always property for page after an element.
Note − The changes would be visible while printing or viewing the print preview.
Example
You can try to run the following code to return the page-break behavior after an element with JavaScript −
<!DOCTYPE html> <html> <body> <h1>Heading 1</h1> <p>This is demo text.</p> <p>This is demo text.</p> <p id = "myFooter">This if footer text.</p> <button type = "button" onclick="display()">Set page-break</button> <script> function display() { document.getElementById("myFooter").style.pageBreakAfter = "always"; } </script> </body> </html>
- Related Questions & Answers
- How to set the page-break behavior inside an element with JavaScript?
- How to set the page-break behavior before an element with JavaScript?
- Usage of page-break-before, page-break-after, and page-break-inside properties in CSS
- How to set the minimum number of lines for an element that must be left at the bottom of a page when a page break occurs inside an element with JavaScript?
- How to set the height of an element with JavaScript?
- How to set the margins of an element with JavaScript?
- How to set the padding of an element with JavaScript?
- How to set the left margin of an element with JavaScript?
- How to set the horizontal alignment of an element with JavaScript?
- How to set the right padding of an element with JavaScript?
- How to set the maximum height of an element with JavaScript?
- How to set the bottom margin of an element with JavaScript?
- How to set the top margin of an element with JavaScript?
- How to set the right margin of an element with JavaScript?
- How to set the maximum width of an element with JavaScript?
Advertisements