【发布时间】:2012-05-01 03:39:27
【问题描述】:
我有一个包含许多不同 DIV 的 HTML 页面,我想打印出用户单击的 DIV 并隐藏所有其余部分。
谁能告诉我如何在 Javascript 中做到这一点?
<html>
<head>
<title>Print Demo</title>
<script type="text/javascript">
<!-- MY JAVASCRIPT FUNCITON -->
</script>
</head>
<body>
<div id="div1">
<a href="<JSMethod>">Print the page with this div</a>
</div>
<div id="div2">
<a href="<JSMethod>">Print the page with this div</a>
</div>
<div id="div3">
<a href="<JSMethod>">Print the page with this div</a>
</div>
</body>
</html>
【问题讨论】:
-
我不确定“页面”是什么意思 - 所有 div 都在同一页面上。您是否想隐藏除单击的 div 之外的所有内容?
-
是的,这正是我想做的!
标签: javascript html printing