js文件作用及使用方法

js文件是一种脚本,可以控制页面达到一些动态效果(控制页面行为的);

例子:

写个js文件 文件名暂定为 a.js
a.js里面的内容如下:
function showTime(){
var time = new Date();
alert(time);
}

写一个html文件 文件名暂定为 b.html(把a.js和b.html放一个文件夹)
b.html里面的内容如下:

<html>
<head><title>time<title/>
<script src="a.js" type="text/javascript"></script>
<head>
<body>
点击显示时间:<input type="button" onclick="showTime()" />
<body/>
<html/>

引用:https://zhidao.baidu.com/question/385590393.html

分享支援 造福人间

猜你喜欢

转载自www.cnblogs.com/cjeandailynotes/p/10430938.html
今日推荐