How about being able to pass in a jquery object and/or dom node to closest()?
Back in 1.3, closest() was a great addition to jquery and I use it all the time. One thing that has
surprised me is that you must pass a selector string; it will not accept a jquery object or dom node (unlike filter()). For example:
- var someDom = $('#foo .bar'); // some saved jquery object
- $('body').click(function(event) {
- $(event.target).closest(someDom); // always returns an empty jquery object
-
$(event.target).closest(someDom.get(0)); // always returns an empty jquery object
-
$(event.target).parents().filter(someDom); // returns jquery[<div class="bar">] when click is in .bar
- });
Anyone else stumble into this? I know that it really isn't too big of a deal, but I've caught myself doing this more than once and it takes some debugging to remind me that filter() and closest() act differently.