UNPKG

@mdui/jq

Version:

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

17 lines (16 loc) 500 B
import { $ } from '../$.js'; import { isString } from '../shared/helper.js'; import './children.js'; import './eq.js'; import './get.js'; import './parent.js'; // eslint-disable-next-line @typescript-eslint/no-explicit-any $.fn.index = function (selector) { if (!arguments.length) { return this.eq(0).parent().children().get().indexOf(this[0]); } if (isString(selector)) { return $(selector).get().indexOf(this[0]); } return this.get().indexOf($(selector)[0]); };