隐藏表格的某一列,jquery应该如何操作?


隐藏某一行这个相对简单点,但是隐藏某一列感觉写起来很复杂啊

html:

<table>
    <tr>
        <td>col 1</td>
        <td>col 2</td>
        <td>col 3</td>
        <td>col 4</td>
    </tr>
    <tr>
        <td>col 1</td>
        <td>col 2</td>
        <td>col 3</td>
        <td>col 4</td>
    </tr>
    <tr>
        <td>col 1</td>
        <td>col 2</td>
        <td>col 3</td>
        <td>col 4</td>
    </tr>
    <tr>
        <td>col 1</td>
        <td>col 2</td>
        <td>col 3</td>
        <td>col 4</td>
    </tr>
</table>​

css:

table {
    margin: 10px;
}
td {
    border: 1px solid #396;
    padding: 10px;
}​

http://jsfiddle.net/zNZN7/

jquery HTML table JavaScript

岩泽麻美. 11 years, 8 months ago

如果你要删掉第一行,下面这行就行

$(document).ready(function(){
    $("table tr td:nth-child(1)").each(function(){
        $(this).remove();
    });
});
摸鱼的Yui answered 11 years, 8 months ago

Your Answer