JavaScript代码段的三种书写位置
1.行内式(代码段在body内)
<input style="button" value="点我" onclick="alert('hello js!')">
2.内嵌(代码在head内)
<script>
alert("hello js!");
</script>
3.外部(代码在head内)
首先新建一个以js为后缀的eg.js文件,并在其内部写下代码
alert('hello js!')
然后在HTML中引入eg.js
<script src="eg.js">
</script>
js的输入(prompt)和输出(alert)以及控制台输出(console)
<script>
prompt('请输入序号');
alert('hello world!');
console.log('只有我能看到');
</script>