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