找回密码
 立即注册

1,javascript第一节教程

[复制链接]
admin 发表于 5 天前 | 显示全部楼层 |阅读模式
1, 1.jpg

2,简单案例:
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>Document</title>
  7.     <script>
  8.       alert("hello world") // 弹窗
  9.       //  document.write("hello world") // 写入页面
  10.       
  11.       console.log("hello world") // 写入控制台
  12.     </script>
  13. </head>
  14. <body>
  15. <div>hello 11111</div>
  16. </body>
  17. </html>
复制代码
3,js放的位置
3.1 行内:
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>Document</title>
  7. </head>
  8. <body>
  9.     <button onclick="alert('hello world')">点我</button>
  10.     <a href="javascript:alert('hello world')">点我</a>
  11. </body>
  12. </html>
复制代码
3.2 内嵌:
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>Document</title>
  7. </head>
  8. <body>
  9.     <div>hello 11111</div>
  10.     <script>
  11.         alert("hello world")
  12.         //  document.write("hello world")
  13.         console.log("hello world")
  14.     </script>
  15. </body>
  16. </html>
复制代码
3.3 外部:
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>Document</title>
  7.     <script src="js/hello.js">
  8.     </script>
  9. </head>
  10. <body>
  11. </body>
  12. </html>
复制代码
hello.js
  1. alert("hello world")
复制代码


QQ|网站地图|Archiver|小黑屋|金黑网络 ( 粤ICP备2021124338号 )

网站建设,微信公众号小程序制作,商城系统开发,高端系统定制,app软件开发,智能物联网开发,直播带货系统等

Powered by Www.Jinhei.Cn

Copyright © 2013-2024 深圳市金黑网络技术有限公司 版权所有

快速回复 返回顶部 返回列表