JavaScript将js文件与html文件分开

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ytlxl/article/details/79978056

html文件:

<!DOCTYPE html>
<html>
<head>
	<title>test4</title>
	<script src="tt.js">
	</script>
</head>
<body>
</body>
</html>

tt.js文件:

person=new Object();
person.firstname="Bill";
person.lastname="Gates";
person.age=56;
person.eyecolor="blue";
document.write(person.firstname+" is "+person.age+" years old.");

猜你喜欢

转载自blog.csdn.net/ytlxl/article/details/79978056