2012-01-13 49 views
0
<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的只有這個:jQuery的Rowspan?

<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> 

屬性最大==行跨度。 這可能嗎?

LIVE:http://jsfiddle.net/fKQSz/

+0

你要轉換的'max'屬性'rowspan'? – Sampson 2012-01-13 02:49:28

回答

2

你可以做這樣的:

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/

0

呃...所以你想:

var td = document.getElementById('one'); 
td.setAttribute("colspan",td.getAttribute("max")); 

是不是這樣?

+1

謝謝,但我還必須在3 TD以下刪除 – 2012-01-13 02:53:44