一、输出内容
1、弹窗
控制浏览器弹出警告框
alert("创造一个浏览器的弹窗")
2、向body输出内容
让计算机在页面中输出一个内容
document.write("");可以向body中输出一个内容
document.write("内容会出现在页面中");
3.向控制台输出内容
在控制台打印内容
console.log("内容")
console.log("向控制台输出内容")
二、编写位置
1.标签--极少使用后
可以将JS代码写在标签的onclick属性中,当我们点击按钮时,js代码会执行
<button onclick="alert('点击后的弹窗')">点我弹窗</button>
超链接的href属性中,点击超链接时会执行
href="javascript:js代码"
<a href="javascript:alert('超链接弹窗');">超链接弹窗</a>
2.script标签内--频率不高
head标签内的script标签里面
<head>
<script>
/*js代码*/
</script>
</head>
3.通过script标签的src属性来引入外部标签。
可以写多个script标签
<script type="text/javascript" src="script.js"></script>
<head>
<script type="text/javascript" src="script.js"></script>
</head>