Hi everyone,

I'm looking for a neat way to pass the index of an element in a
wrapped to an event handler bound to that element.

Like so:

$(container).find('a[href$=.jpg]').bind('click', {}, function (e) {
// I want to access the index of the clicked element inside the
wrapped set here
doStuff(indexOfThisElement);
});


Now, I can access it through:
indexOfThisElement = $('a[href$=.jpg]',container).index(this);

But I feel like there may be a more efficient way of doing this? Is
there a way to attach the index of the current element to the
event.data object passed to the event handler perhaps?

Anyone got an idea?

Reply via email to