一、javascript代码引入位置
1. alert('helloworld')
=> 弹出一个对话框,显示括号中内容
行内式
直接在html属性中写javascript代码
1. 没有默认行为的html标签
<div οnclick="alert('helloworld')">点击我</div>
2. 有默认行为的html标签
<a href="javascript:alert('百度')">百度</a>
<form action="">
内嵌式
<script type="text/javascript">
alert('内嵌式引用js代码')
</script>
注:位置 body结束标签前
外链式
<script src="./test.js"></script>
二、 js注释
单行注释 // ctrl + /
多行注释 /* 内容 */ ctrl + shift + /
<body>
<div onclick="alert('helloworld')">点击我</div>
<!-- 默认行为 -->
<!-- <a href="http://www.baidu.com">百度</a> -->
<a href="javascript:alert('百度')">百度</a>
<script type="text/javascript">
/*
alert('内嵌式引用js代码')
alert('1111')
alert('2222')
*/
</script>
<!-- <script src="./test.js"></script> -->
</body>