Every line of 'jquery find parent with class' 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.
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 }
69 function findParentWithClass(element, parentClass) { 70 var parent = element.parentNode; 71 while (!$(parent).hasClass(parentClass)) { 72 parent = parent.parentNode; 73 } 74 return parent; 75 }
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 }
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 }
81 function findParent(inEl: Element, className: string): ?Element { 82 var el = inEl; // this is for Flow. 83 do { 84 if (el.classList.contains(className)) return el; 85 el = el.parentElement; 86 } while (el); 87 return null; 88 }
57 export function findElementParentByClassName(element, className, includeSelf) { 58 let el; 59 if (includeSelf === false) { 60 el = element.parentElement; 61 } else { 62 /** @type {HTMLElement} */ 63 el = (element); 64 } 65 while (el != null && !el.classList.contains(className)) { 66 el = el.parentElement; 67 } 68 return el; 69 }
490 function closestParent(child, className) { 491 if (!child || child == document) { 492 return null; 493 } 494 if (child.classList.contains(className)) { 495 return child; 496 } else { 497 return closestParent(child.parentNode, className); 498 } 499 }
4 export function findParent(el: any, selector: string): any { 5 let retEl = null; 6 while (el) { 7 if (el.matches(selector)) { 8 retEl = el; 9 break; 10 } 11 el = el.parentElement; 12 } 13 return retEl; 14 }
11 export function findParent (el, selector) { 12 while (el) { 13 if (el.is(selector)) return el 14 el = el.getParent() 15 } 16 }
20 export function queryClosestParent(elem, selector) { 21 22 // Element.matches() polyfill 23 if (!Element.prototype.matches) { 24 Element.prototype.matches = 25 Element.prototype.matchesSelector || 26 Element.prototype.mozMatchesSelector || 27 Element.prototype.msMatchesSelector || 28 Element.prototype.oMatchesSelector || 29 Element.prototype.webkitMatchesSelector || 30 function(s) { 31 var matches = (this.document || this.ownerDocument).querySelectorAll(s), 32 i = matches.length; 33 while (--i >= 0 && matches.item(i) !== this) {} 34 return i > -1; 35 }; 36 } 37 38 // Get the closest matching element 39 for ( ; elem && elem !== document; elem = elem.parentNode ) { 40 if ( elem.matches( selector ) ) return elem; 41 } 42 return null; 43 };