Q:

jquery selector exclude elements containing input with focus

I spent quite a bit of time trying to come up with this today to no avail.
I'm trying to select rows in a table having visible input elements but excluding the row that contains the input with focus.
My best guesses:
$('tr:has(input:visible)').not('tr:has(input:focus)')
$('tr:has(input:visible):not(:has(input:focus))')

Neither of these remove the row with the focused input. I read that :focus is a pseudo selector, is that part of my problem or is that a label for everything with a colon?
Is it possible to do this within the selector? I could also just loop through manually with a conditional, but I'd like to be able to avoid that.

A:

You could use .filter() to return tr elements with input elements that aren't focused.
In this case, .is(':focus') is used to determine whether the child input is focused. If it isn't, then it is returned and added to the collection of tr elements.
Example Here
var tr = $('tr:has(input:visible)').filter(function () {
    return !$('input', this).is(':focus');
});

Based on this example, though, it looks like both of your original jQuery selectors were working properly. Perhaps you are querying the DOM when the input element doesn't have focus?

