0
我对jquery很新颖,我试图用它在我的非常简单的网页底部放置一个打印按钮,但我无法让它显示出来。 (我将有更多的内容在页面上进行打印,我简单没有包括它尚未因为它是没有必要的),这里是我的代码至今:JQuery打印按钮没有显示
<html>
<head>
<h1>This is my webpage</h1>
</head>
<body>
<div class="col_2">
<script>
<img src="print.png" class="printMe" alt="Print" title="Print"></a>
$('.printMe').click(function(){
window.print();
});
</script>
<img src="gvsu.png">
<a href="https://www.linkedin.com"><img src="linkedin.png" alt="HTML tutorial" width="42" height="42"></a>
<a href="https://www.twitter.com"><img src="twitter.png" alt="HTML tutorial" width="42" height="42"></a>
<a href="https://www.facebook.com"><img src="fb.png" alt="HTML tutorial" width="42" height="42"></a>
</div>
</body>
</html>
为了加快页面加载时间,脚本应该位于页面的底部,而不是页眉。只有CSS应该在标题中。 – RaviH
您应该将脚本放入页脚或等待DOM准备就绪。将脚本包装在'$(document).ready()'中。 – Konsole