一、将JS代码,插入到head区域,即可在网页打开时执行。
示例:
1 2 3 4 5 6 7 | < html > < head >< title >test</ title ></ head > < script > alert("已经开始执行函数!"); </ script > < body ></ body > </ html > |
二、调用js文件
① 在head中引入js文件
<script src="/js/article/showAllArticle.js"></script>
② js文件写法
$(document).ready(function() {
alert("执行了...");
});