admin管理员组文章数量:1404340
I am using the script below:
<script>
function printpage()
{
window.print()
}
</script
To call it after with this:
<input type="button" value="Print this page" onclick="printpage()" />
But I don't know how to insert in the script this:
$('input' )
.hide();
Meaning that all the input from the print area is hidden.
Any ideas?
I am using the script below:
<script>
function printpage()
{
window.print()
}
</script
To call it after with this:
<input type="button" value="Print this page" onclick="printpage()" />
But I don't know how to insert in the script this:
$('input' )
.hide();
Meaning that all the input from the print area is hidden.
Any ideas?
Share Improve this question edited Sep 29, 2012 at 16:08 Daniel Li 15.4k6 gold badges44 silver badges60 bronze badges asked Sep 28, 2012 at 19:35 Lefteris LivanosLefteris Livanos 1011 silver badge9 bronze badges 4- You need a '.' infront of the input to get all input classes using jquery. – C0D3 Commented Sep 28, 2012 at 19:37
-
function printpage(){ $('input' ).hide(); window.print(); }
– Jashwant Commented Sep 28, 2012 at 19:38 - not working , now i cant print – Lefteris Livanos Commented Sep 28, 2012 at 19:49
-
1
@c0d3Junk13 Using
$("input")
gets all<input>
elements...Their input element doesn't have a class anyways – Ian Commented Sep 28, 2012 at 19:51
2 Answers
Reset to default 12You can solve this using CSS by specifying the media type as print
:
<style type="text/css" media="print">
/*<![CDATA[*/
input{
display:none;
}
/*]]>*/
</style>
Use @Media CSS rule:
@media print {
input {visibility:hidden;}
}
or
@media print {
input {display:none;}
}
The choice between these options depends on your page flow: display:none removes the input pletely, while visibility:hidden simply hides it, but it still occupies its place.
You don't need to hide it in JavaScript.
本文标签: javascriptHow can I hide my inputs when printing my webpageStack Overflow
版权声明:本文标题:javascript - How can I hide my inputs when printing my webpage? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744793623a2625444.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论