code: function(el, s) { //el is the element and s the selector of the closest item to find
        // source http://gomakethings.com/climbing-up-and-down-the-dom-tree-with-vanilla-javascript/
        var f = s.charAt(0);
        for (; el && el !== document; el = el.parentNode) { // Get closest match
          if (f === '.') { // If selector is a class
            if (document.querySelector(s) !== undefined) {
              return el;
            }
          }
          if (f === '#') { // If selector is an ID
            if (el.id === s.substr(1)) {
              return el;
            }
          }
        }
        return false;
        }
docs: Native Javascript for Bootstrap 3 | Internal Utility Functions by dnp_theme