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()
}