<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Nearth</title> <script> /* =====对象的学习===== */ var person{ name:"rebool", sex:"男", age:12, /* eat:function(){ alert("我要吃饭了哒·······"); }, */ play:function(){ alert("我要和主人去玩了哒·····"); } } var eat=function(){ alert(我要去吃饭哒呀········); } function btn1_onclick(){ eat(); } function btn2_onclick(){ person.play(); } </script> </head> <body> <input type="button" name="btn1" id="" value="按键1"onclick="btn1_onclick()"/> <input type="button" name="btn2" id="" value="按键2"onclick="btn2_onclick()"/> </body> </html>
Nearth===>WEB前端--第20课/js对象学习
最新推荐文章于 2019-11-08 11:49:14 发布