Every line of 'find closest class jquery' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
45 function JQueryClosestByClass(element, clazz) { 46 while (element) { 47 if (JQueryHasClass(element, clazz)) { 48 return element; 49 } 50 element = element.parentNode; 51 } 52 return null; 53 }
179 function closest(el, selector) { 180 while (el) { 181 if (matches(el, selector)) { 182 return el; 183 } else { 184 el = el.parentElement; 185 } 186 } 187 return false; 188 }
10 function closest(element, selector, top = document.body) { 11 while (!element.matches(selector)) { 12 element = element.parentNode 13 if (element === top) { 14 return null 15 } 16 } 17 return element 18 }
260 function closest(element, selector) { 261 if (element.closest) { 262 return element.closest(selector); 263 } 264 var el = element; 265 while (el) { 266 if (matches(el, selector)) { 267 return el; 268 } 269 el = el.parentElement; 270 } 271 return null; 272 }
99 function findParent ($elt, className) { 100 while ($elt) { 101 if ($elt.hasClass(className)) 102 return $elt; 103 $elt = $elt.parent(); 104 } 105 return null; 106 }
12 function closest(element, selector) { 13 var matchesFn; 14 15 // find vendor prefix 16 ['matches', 'msMatchesSelector'].some(function(fn) { 17 if (typeof document.body[fn] == 'function') { 18 matchesFn = fn; 19 return true; 20 } 21 return false; 22 }) 23 24 var parent; 25 26 // Traverse parents 27 while (element) { 28 parent = element.parentElement; 29 if (parent && parent[matchesFn](selector)) { 30 return parent; 31 } 32 element = parent; 33 } 34 35 return null; 36 }
69 function findParentWithClass(element, parentClass) { 70 var parent = element.parentNode; 71 while (!$j(parent).hasClass(parentClass)) { 72 parent = parent.parentNode; 73 } 74 return parent; 75 }
68 export function closest (element, selector) { 69 while (element && element.nodeType === 1) { 70 if (matches(element, selector)) { 71 return element 72 } 73 74 element = element.parentNode 75 } 76 77 return null 78 }
22 export function closest(element: Element, selector: string): Element | null { 23 return closestCallback(element, (el: Element) => matches.call(el, selector)) 24 }
23 function closest(selector, context) { 24 var nodes = []; 25 _util.each(this, function (node) { 26 while (node && node !== context) { 27 if (_index.matches(node, selector)) { 28 nodes.push(node); 29 break; 30 } 31 node = node.parentElement; 32 } 33 }); 34 return _index.$(_util.uniq(nodes)); 35 }