gpt4 book ai didi

javascript - Rowspan 与 jQuery?

转载 作者:行者123 更新时间:2023-12-02 19:54:22 26 4
gpt4 key购买 nike

<table>
<tr><td>aaa</td><td id="one" max="3">aaa</td><td>aaa</td><td>aaa</td></tr>
<tr><td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr><td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr><td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
</table>

table td {
padding: 3px;
border:solid 2px red;
}

我想仅使用 jQuery 接收:

<table>
<tr><td>aaa</td><td rowspan="3">aaa</td><td>aaa</td><td>aaa</td></tr>
<tr><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr><td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
</table>

属性 max == rowspan。这可能吗?

直播:http://jsfiddle.net/fKQSz/

最佳答案

你可以这样做:

var start = $('#one');
var n = start.attr('max');
start = start.prop('rowspan',n).parent();
var idx = start.index();

while(--n) {
start = start.next();
start.children().eq(idx).remove();
}

http://jsfiddle.net/fKQSz/4/

关于javascript - Rowspan 与 jQuery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8845267/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com