UNPKG

@mdui/jq

Version:

拥有和 jQuery 相似 API 的轻量级 JavaScript 工具库

20 lines (19 loc) 499 B
import { $ } from '../$.js'; import { JQ } from '../shared/core.js'; import './eq.js'; import './is.js'; import './parents.js'; // eslint-disable-next-line @typescript-eslint/no-explicit-any $.fn.closest = function (selector) { if (this.is(selector)) { return this; } const matched = []; this.parents().each((_, element) => { if ($(element).is(selector)) { matched.push(element); return false; } }); return new JQ(matched); };