如何打印出 jQuery 方法链中的最终选择器

How to print out the final selector in a jQuery method chain

如果我有以下jQuery链

 let mpath = $('.wlc2022.confirm').find('.something');

如何将“.something”或“something”(以 jQuery 或原始 JavaScript 语法)打印到控制台 window 因为它是最后一个选择器 mpath 正在寻找?

我试过了...

console.log(mpath.val)
console.log(mpath.value)

但到目前为止还没有...

jQuery 的现代 (post-3.0) 版本中没有 API。 jQuery objects 上曾经有一个 .selector 属性,但是因为不可靠被移除了

还要注意 mpath 本身并不是在“寻找”任何东西;它得到基于 jQuery 的表达式的结果。做你想做的事情的最好方法可能是围绕该表达式模式构建某种实用程序,并让它保留最后一个选择器并以某种方式使其可用。