I use some jQuery to highlight form fields. But not the input field itself gets highlighted but its parent. And I want to specify those parents.
Here the parent is div and it works fine
$("div input").focus(function () {
$(this).parent().addClass("focus");
});
But I want to specify the parent “td” too like this
$("div,td input").focus(function () {
$(this).parent().addClass("focus");
});
But this does not work. Only td fields get the focus attribute! Any idea how to handle this?
A comma will completely separate two selectors; you need to specify
inputtwice:Alternatively, if you don’t have many
<input>s that don’t match this criteria, you can make it a little neater: