Skip to content

This in js

Sébastien LUCAS edited this page Jan 24, 2015 · 4 revisions
$.fn.doSomethingWithElements = function() {
    var $this = this;

    this.each(function() {
        // `this` refers to each element and differs each time this function
        //    is called
        //
        // `$this` refers to old `this`, i.e. the set of elements, and will be
        //    the same each time this function is called
    });
};

WIKI by Sébastien Lucas CEO & Funder or Bricks

Clone this wiki locally