Never mind, figured out the issue.  the "return" statement has a call
that will look for label inside of the parent, not look at the parent
itself.  If I want to look at the parent, I'll have to use "$(this).is
('label')".  Sorry for the clutter!

On Jun 11, 12:11 pm, TimW66 <timwilso...@gmail.com> wrote:
> Hi all, I have the following JS code:
>
>         $('table.tableView :inp...@readonly]').parent().filter(function() {
>                 return !$('label', this).length;
>         }).addClass('readonly');
>
> ------
>
> And the following HTML code:
>
>         <table class="tableView">
>                 <thead>
>                         <tr>
>                                 <th>test</th>
>                         </tr>
>                 </thead>
>                 <tbody>
>                         <tr>
>                                 <td>
>                                         <label for="foo">Foo</label>
>                                         <input id="foo" type="text" 
> value="foo" readonly="readonly"/>
>                                 </td>
>                         </tr>
>                         <tr>
>                                 <td>
>                                         <input id="bar" type="text" 
> value="bar" readonly="readonly"/>
>                                 </td>
>                         </tr>
>                         <tr>
>                                 <td>
>                                         <label for="zed">Foo
>                                                 <input id="zed" type="text" 
> value="zed" readonly="readonly"/>
>                                         </label>
>                                 </td>
>                         </tr>
>                 </tbody>
>         </table>
> ------
>
> What I expected is the first and third input box to not get the
> readonly class.  However, the third input box does get the readonly
> class.  Isn't "<label>" a parent of "<input>"?
>
> I should also mention I'm using jQuery v1.2.6.

Reply via email to