Reputation: 1379
I am dealing with templates and finding certain elements for future updating when responding to events. However, I'd like the ability to mark these elements with a class, data-* attribute, or something else without having to know the markup beforehand.
Is there a way to perform a .filter() and a .find() search at the same time?
Upvotes: 1
Views: 78
Reputation: 4362
Simple extension for this purpose:
jQuery.fn.findIn = function(selector){
return this.filter(selector).add(this.find(selector));
}
Then simply call .findIn('.your-selector')
.
currently taking suggestions for a better name.
Upvotes: 0