Select all table cells but not inline table cells

How to select cells in a table but not cells in an embedded table? The question is how to do this in jQuery . I need to do this in CSS.

<table id="Outer">
    <tr>

        <td> --this one
        </td> 

        <td> --this one
            <table>
                <tr>
                    <td></td> -- but not this one or any deeper nested cells
                </tr>
            </table>
        </td>

    </tr> 
</table>
+5
source share
2 answers

You can use>, a child selector.
Example:

table#Outer > tbody > tr > td { color: red; }

The child selector selects only direct children . More information on the child selector: http://meyerweb.com/eric/articles/webrev/200006b.html . But it is not supported by every web browser: http://www.quirksmode.org/css/contents.html .

+13
source

:

table#Outer > tbody > tr > td {  }

, - , :

td { background-color: white; }
table#Outer > tbody > tr > td { background-color:red; }

http://jsfiddle.net/95NAd/

+2

All Articles