jQuery不适用于fadeOut [英] jQuery not working for fadeOut
问题描述
我得到此代码用于测试目的,这很简单,当我在Firefox中打开它进行调试时,它无法正常工作,所有内容似乎都已加载好,这很奇怪,对此有何想法? .非常感谢
I got this code for testing purpose, it's very simple , when I open it in Firefox for debugging, it's not working, everything appears to be loaded and fine, it's very weird, any thoughts on this? . many thanks
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Hover Over effect jQuery</title>
<link rel="stylesheet" href="css/style.css">
<script type="text/javscript" src="js/jquery-1.10.2.min.js">
jQuery(document).ready(function($) {
$("img").click(function(event) {
$(this).fadeOut('slow');
});
});
</script>
</head>
<body>
<div class="viewport">
<a href="#">
<img src="images/renew.jpg">
</a>
<div class="caption"><span>Caption goes here</span>
</div>
</div>
</body>
</html>
推荐答案
更改此内容:
<script type="text/javscript" src="js/jquery-1.10.2.min.js">
jQuery(document).ready(function($) {
$("img").click(function(event) {
$(this).fadeOut('slow');
});
});
</script>
对此:
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("img").click(function(event) {
$(this).fadeOut('slow');
});
});
</script>
使用src
属性加载外部脚本时,如果请求成功,浏览器将忽略<script>
标记的内容.解决方案很简单,只需添加另一个脚本标签即可.
When you load an external script using the src
attribute, the browser will ignore the contents of the <script>
tag if the request is successful. The solution is easy, just add another script tag.
您还应该删除<!DOCTYPE html>
之前的<html>
.这是没有意义的,也是错误的.另外,如果这是整个文档,则最后需要一个</html>
.
You should also remove the <html>
that is before your <!DOCTYPE html>
. It is pointless and wrong. Also, if this is the entire document, you need a </html>
at the very end.
这篇关于jQuery不适用于fadeOut的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!