Hello I am completely new to JavaScript and I am trying to do something , but I can't understand when I call this function:
this.start = function () {
this.interval = setInterval(startIncrement.call(this) , 1000);
}
startIncrement only executes once. I am trying to do Counter class that generates two buttons(start and stop) and one textbox.So when I do:
var a = new Counter(); // generates object of Counter
a.init(); // generates the HTML (did that part)
a.start(); //start increasing the value of text box over period of time
a.stop(); // stops the counting (did that part)
And buttons start and stop simply have onclick event that call start and stop methods of Counter. I tried all answers of this question setInterval only runs once on object method but it didn't work and now I am stuck.