jqueryangularjsjqlite

Instead of $.closest in Angularjs


I want to implement this code in directive but in jQLite this doesn't work How should this be done?

 var thisCell = element.closest('.sampleclass');

Solution

  • You have to implement this functionality manually, for example:

    var thisCell = (function closest(e, className) {
      if (e[0].nodeName == "HTML") {
        return null;
      } else if (e.hasClass(className)) {
        return e;
      } else {
        return closest(e.parent(), className);
      }
    })(element, "sampleclass");