خرید بک لینک

Vote count: 0

I want to make Generator class as a parent, and a number of child. So i define default constructor and parent function like this:

  function Generator (){
   this._startIndex=0;
    this._endIndex=61;
    alert("Generator Ready " + this._startIndex + " " + this._endIndex);
}

Generator.prototype.make=function() {
    alert (this._startIndex);

} 
var worker= new Generator();

document.getElementById("but0").addEventListener("click", worker.make);

but in this case "this" is a Button, and this._startIndex is undefined.

In case, i call function like:

document.getElementById("but0").addEventListener("click", worker.make(warker._startIndex));

The function called not on click, but onload. I shure, this is simple question, but more than hour i cant find the answer.

asked 3 mins ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 2 اسفند 1394 ساعت: 22:32

صفحه بندی