如何使用 JavaScript 设置元素后的分页行为?
javascriptobject oriented programmingfront end technology更新于 2024/6/29 22:04:17
使用 JavaScript 中的 pageBreakAfter属性设置元素后的分页行为。使用 always 属性设置元素后的分页行为。
注意 − 更改将在打印或查看打印预览时可见。
示例
您可以尝试运行以下代码以使用 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>
相关文章
有用资源
javascript 参考教程 - 该教程包含有关 javascript 的更多信息:https://www.cainiaomax.com/javascript/

