目录
Javascript书写位置
内嵌式写法
外联式写法[推荐写法]
行内式写法[不推荐]
内嵌式写法 < script type = "text/javascript" > js < /script> 注意: 该标签可以放到 head 标签中或者 body 标签中 外联式写法[推荐写法] 1. 新建 js 文件 2. 通过 script 标签引用到当前页面中 < script type = "text/javascript" src = "test.js" >< /script> H5 的 script 标签现在可以不 加 type 属性他默认你是 type="text/ javascript " 注意: 1. 不能将代码写到外联式标签中。 ---- 不会执行 2. 一个网页中可以同时调用多个外部 js 文件 < script type = "text/javascript" src = "test.js" >< /script> < script type = "text/javascript" src = "test.js" >< /script> < script type = "text/javascript" src = "test.js" >< /script> < script type = "text/javascript" src = "test.js" >< /script> 行内式写法[不推荐] < div onclick = "js 代码 " >< /div> 注意: onclick 是一个点击事件: 当点击 div 的时候,会触发该事件,执行该事件中的代码 特殊情况下使用
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)