HTML页面
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="js/lianxi.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<h1>Hello World !!!!</h1>
</body>
</html>
js代码
var student=new Object();
student.username="alex";
student.age=12;
student.sex="女";
student.grade=45;
student.eat=function(){
alert(this.username+"吃饭");
}
student.study=function(){
alert(this.username+"学习");
}
student.sport=function(){
alert(this.username+"运动");
}
student.eat();
student.study();
student.sport();