求大神帮做一下一个点击木头掉木头的js,我以前的js找不到了,求大神
1个回答
展开全部
function Wood() {
this.num = 1000;
this.body();
}
Wood.prototype = {
fell : function (that) {
that.num = that.num - 1;
return "这棵树还剩下:" + that.num + "木头";
},
body : function () {
var that = this;
var body = document.createElement("input");
body.type = "button";
body.value = "这棵树还剩下:" + this.num + "木头";
body.onclick = function () {
this.value = that.fell(that);
}
document.body.appendChild(body);
}
}
window.onload = function () {
var woods = new Wood();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询