如何获取jQuery选择器的文本表达式? [英] How do I get a jQuery selector's expression as text?
问题描述
我有一个jQuery选择器,它具有链式功能.
I have a jQuery selector, which has a chained function.
在函数中,我想访问表示选择器表达式的TEXT.
Inside the function I want to get access to the TEXT representing the expression for the selector.
$("cat dog").function() {
// how do I get access to the "cat dog" string from inside THIS function ?
};
在此代码示例中,我已经过度简化了实际要做的事情.我正在编写一个插件,我需要访问为其创建包装集的选择器.显然,在此特定示例中,由于我编写了猫狗",因此我可以使用它.因此,只需将其想象在插件中即可.
I've over simplified in this code sample what I actually want to do. I'm writing a plug-in and I need access to the selector for which the wrapped set has been created. Obviously in this particular example I have access to "cat dog" becasue i wrote it. So just picture this being in a plugin.
为此,Google会遇到一些麻烦.
Its a little tricky to google for this.
编辑:很遗憾,现在不推荐使用选择器"属性. http://jquery.com/upgrade-guide/1.9/#selector-property-on-jquery-objects
edit: the 'selector' property is unfortunately now deprecated. http://jquery.com/upgrade-guide/1.9/#selector-property-on-jquery-objects
推荐答案
jQuery对象中有一个'selector'属性,但是我不确定它是否始终可用.
There is a 'selector' attribute in the jQuery object, but I'm not sure it's always available.
这篇关于如何获取jQuery选择器的文本表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!