Html file code I just tried the simple Hello World in javascript file
这是我无意使用console.log在控制台中显示消息。我使用了Atom,并在Chrome中打开了它,按inspect,进入控制台,但没有消息。
[如果我们分别创建html
和javascript
文件,则必须在javascript
中将html
文件指定为外部javascript
文件。因此,在以上示例中,必须将<script src="index.js"></script>
添加到html
。
下面提供完整的代码示例。
[C0的内容:
index.html
和<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Hello World with JS</title>
</head>
<body>
<p>See the browser console for the console output.</p>
<script src="index.js"></script>
</body>
</html>
:
index.js
关于console.log("Hello World!")
和javascript
一起使用html
的更多详细信息。