我正在尋找添加一個屬性(href)到一個表的td。jQuery添加href字符串
我想jQuery會工作!
我需要幫助,請...
網址:http://mysite
原始表:
<table>
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Url</th>
</tr>
</thead>
<tbody>
<tr class='Collection'>
<td>Collection</td>
<td>Collection1</td>
<td>/Collection1</td>
</tr>
<tr class='Site'>
<td>Site</td>
<td>Site1</td>
<td>/site1</td>
</tr>
</tbody>
</table>
那麼結果將是:
<table>
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Url</th>
</tr>
</thead>
<tbody>
<tr class='Collection'>
<td>Collection</td>
<td>Collection1</td>
<td><a href="http://mysite/Collection1">/Collection1</a></td>
</tr>
<tr class='Site'>
<td>Site</td>
<td>Site1</td>
<td><a href="http://mysite/site1">/site1</a></td>
</tr>
</tbody>
</table>
td沒有href屬性。 – eugeneK 2012-08-08 12:09:17
我試過$(「td:eq(2)」)。each(function(){(').appendTo('td') 但它沒有工作 – user472285 2012-08-08 12:13:57
你應該追加到$這個)。因爲每個循環思考tds的列表 – eugeneK 2012-08-08 12:18:18