[jQuery] Don't focus a readonly field
Hi all,
I have a table that I will usually want to focus the first input box
in the first column in the last row. Something like this:
<table>
<tbody>
<tr>
...
</tr>
<tr>
<td>
<input> <-- selects this one
<input type="hidden">
</td>
<td>
<input>
</td>
</tr>
</tbody>
</table>
And I use this to do that part:
$('tbody>tr:last-child>td:first-child>input').focus().select();
The problem is, in some cases, that input field is readonly, so I
don't want to select it. I want to select the input in the next TD.
If an input is readonly, the parent TD has the "readonly" class. I
tried the following, but they didn't work:
$('tbody>tr:last-child>td:not(readonly):first-
child>input').focus().select();
$('tbody>tr:last-child>td:not([@readonly]):first-
child>input').focus().select();
$('tbody>tr:last-child>td[@readonly]):first-
child>input').focus().select();
$('tbody>tr:last-child>td:not([@class="readonly"]):first-
child>input').focus().select();
I think the last one is close, but the parent TD could also have
another class.
Can anyone help?