引入JavaScript代码和引入css代码类似,可以在head标签或者body标签里面添加
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
alert("hello word");
</script>
</head>
<body>
</body>
</html>
除此之外,还可以使用link标签引入js文件,如:
<link src=”javascript.js>
注意一定要写双标签,不能写单标签(这点不同css),否则容易出错。
alter(“string”)是在网页里面弹出提示框的代码,string代表弹出的内容。