我正在寻找添加一个属性(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