There is allready such an attribute.... try this: $("#myID .MyClass mychildren").myfunction() { console.log(this.selector); // "#myID .MyClass mychildren" }
On 4 Sep., 01:19, Tzury <[EMAIL PROTECTED]> wrote: > I just released a new version of the HotKeys plug in which was the > reason I needed this new .query property > see more athttp://code.google.com/p/js-hotkeys/wiki/about > > Thank you all, > Tzury > > On Sep 1, 3:46 pm, Ariel Flesler <[EMAIL PROTECTED]> wrote: > > > prevObject is internal, you don't need to know about it. Just use > > end() instead. > > > -- > > Ariel Fleslerhttp://flesler.blogspot.com/ > > > On Sep 1, 9:19 am, Tzury <[EMAIL PROTECTED]> wrote: > > > > > jQuery.fn.find=function( selector ) { > > > > this.query=selector; //this is the only line you have to modify > > > > > var elems = jQuery.map(this, function(elem){ > > > > return jQuery.find( selector, elem ); > > > > }); > > > > return this.pushStack( /[^+>] [^+>]/.test( selector ) || > > > > selector.indexOf("..") > -1 ? > > > > jQuery.unique( elems ) : elems ); > > > > > } > > > > > Now you can get the query string: > > > > $('body .class').prevObject.query //->'body .class' > > > > $('body').find('.class').prevObject.prevObject.query //->'body' > > > > but > > > > $('#id').prevObject.query //->undefined > > > > $().find('#id').prevObject.query //->'#id' > > > > here is the final tweak, > > > (after adding this modified find method) > > > > query = (this.prevObject && this.prevObject.query) || this[0]; > > > > I strongly believe that such property should be added to the main > > > distro of jQuery. > > > After all, the idea of find-and-modify approach - one of jQuery > > > fundamentals.