Home>

In JavaScript, the object this refers to changes from time to time.This will cause the program,Confusion, the general approach is to save this in a variable first,I'm not afraid she will change,Let's look at a small example first

var a=function () {
   this.star=functiont () {};
   this.beg=function () {
    var that=this;
    $node.click (function () {
       //this.start();//this here refers to the $node object
        that.start ();
    });
  };
}

jquery provides a proxy method, which can bind to an object,This has changed, I ’m not afraid or afraid,that when this, I am not afraid not afraidproxy has you showing up,Object change,I'm not afraid......

$node.on ("click", $. proxy (function () {
   this.start ();
}, this)
  • Previous Two simple implementations of JavaScript numerical thousands formatting
  • Next JS implementation of digital format thousandths mutual conversion method