构造函数里面加上
this.PrintCard = PrintCard;就可以了
function Card(name,address,work,home){
this.name=name;
this.address=address;
this.workphone=work;
this.homephone=home;
this.PrintCard = PrintCard;
}
你的js都没有触发语句,怎么会有执行呢
比如说可以写上 onload='playJs()'
然后你把
sue=new Card("Sue Suthers","123 steet","65536", "6493304");
jack=new Card("Jack sheable","765 street","76253","6422906");
henry=new Card("Henry Tillman","233 Elm Street","64788","6414620");
sue.PrintCard();
jack.PrintCard();
henry.PrintCard();
封装起来做为 playJs()
这样应该可以了吧
你body里面的调用不过是告诉电脑我将可能使用./cardtext.js这个文件,而不是让这个文件自动运行