jQuery Expression Reference

Plans

Does anyone know if there is a way to get the expression that returned an object in jQuery from within it’s handler?

Example:

$('body > a').click(function() {
   // Is there any way I can alert 'body > a' in here?
   // Perhaps something like: alert($(this).expression); ?
});

2 Responses to “jQuery Expression Reference”

  1. Damien

    I don’t remember any method for it, and looking at the source, I don’t think it save it somewhere.

    http://jqueryjs.googlecode.com/svn/tags/1.2.6/src/core.js

  2. Mark O’Sullivan - Blog » Blog Archive » jQuery 1.3

    [...] a few weeks ago I was looking for a way of accessing the selector from within the method, and now you can do it. [...]

Leave a Reply