目录
- <html>
- <head>
- <meta charset="utf-8" />
- <title>title>
-
- head>
- <body>
-
- <div id="div">div>
-
- body>
-
- html>
- <script>
- alert("hello,js")//提示信息
- var divEle = document.getElementById("div");
- divEle.innerHTML='hello,js'
- script>
-
通过script来进行定义js。script标签可以放着head标记中,也可以放在body中,也可以放在最后。
<input type="button" value="点击" onclick="alert('点我干嘛??');"/>
按钮借助事件【onclick】来触发js代码
- <html>
- <head>
- <meta charset="utf-8" />
- <title>title>
-
- head>
- <body>
-
- <div id="div">div>
-
- body>
- <script>
- alert("hello,js")//提示信息
- var divEle = document.getElementById("div");
- divEle.innerHTML='hello,js'
- script>
- html>
-
-
创建js文件
alert("我是外部的js")
html页面通过