我的 jquery 代码无法在任何浏览器中运行


My jquery code does not run in any browser

我的jquery在任何浏览器中都不起作用,我在网络上参考了许多答案,因为它没有帮助我..!!

这是我的代码在索引文件中,我尝试了两个(索引.html) 和 (索引.php)

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Jquery</title>
</head>
<body>
<div id="message" style="display:none;"> Welcome to my site</div>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/fade.js"></script>
</body>
</html>

JavaScript文件位于JS文件夹中。

入淡出.js代码是:-

$(document).ready(function() {
$('#message').fadeIn('slow'); 
});
jquery

代码是我从jquery网站下载的我尝试了版本 1 和 2 的生产以及其他源链接,例如

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>

还有一些用户使用的jQuery源链接。我也试图将脚本代码移到标签上方。但不管是什么,我都尝试不在任何浏览器中工作。

请帮帮我...!!

fucntion应该在脚本之前function并加载jQuery

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
$(document).ready(function() {
                  /*^^^^^^*/
    $('#message').fadeIn('slow');
});

尝试调用 jQuery 提供的函数之前,您必须加载 jQuery。交换脚本标记的顺序。

然后查看您的 JavaScript 错误控制台。它会抱怨你拼写错误function fucntion.

只需复制/粘贴以下内容:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Jquery</title>

<script type="text/javascript" src="js/jquery.js"></script>
<script>
$(document).ready(function() {
$('#message').fadeIn('slow'); 
});
</script>
</head>
<body>
<div id="message" style="display:none;"> Welcome to my site</div>
</body>
</html>