【发布时间】:2018-07-20 05:22:52
【问题描述】:
这是我的 HTML 文件的内容:
<!DOCTYPE html>
<!-- The above DOCTYPE declaration tells the browser that this page conforms to HTML 5 standards -->
<head>
<meta http-equiv="author" content="Chris" />
<link href="jquery.css" type="text/css" rel="stylesheet" />
</script>
<script src="js/jquery-3.3.1.min.js">
</script>
<script>
$(document).ready(function() {
$('#message').hide();
});
</script>
</head>
<body>
<p id="message">Hello World!</p>
</body>
</html>
我有一个名为 jquery.js 的文件,它是 jQuery 3.3.1 的缩小版本,它保存在我的 HTML 文件和 CSS 文件所在的文件夹 js 中。在本文档中,我尝试使用 hide() 函数隐藏 ID 为 message 的段落,但是当我在 Google Chrome 浏览器中打开该文件时,该段落仍然存在。
注意:很明显,我是 JavaScript 和 jQuery 库实现的新手。
【问题讨论】:
-
也在此处发布控制台消息
-
你能分享一下 html、css 和 js 的确切文件结构吗
-
我做错了什么?
-
看起来您的 jquery 文件路径错误。如果您的 html 和 jquery 文件都在同一个文件夹中,您可以尝试使用
<script src="jquery-3.3.1.min.js">吗 -
更新代码:
标签: javascript jquery html function selector