这是我使用的标记
<table cellpadding="0" cellspacing="0" border="0">
<thead>
<tr class="tr-head">
<th>Amount Owed</th>
<th>Amount Paid</th>
<th>Check / Cash / Online</th>
<th></th>
</tr>
</thead>
<tbody>
<tr class="row0">
<td>$10 <input type="text" name="amount_owed" id="amount_owed" value="10" style="display: none; width: 40px;" /></td>
<td>$20 <input type="text" name="amount_paid" id="amount_paid" value="20" style="display: none; width: 40px;" /></td>
<td>$30 <input type="text" name="check_cash_online" id="check_cash_online" value="30" style="display: none; width: 40px;" /></td>
<td><a href="javascript:void(0);" class="edit-row" title="row0">Edit</a></td>
</tr>
<tr class="row1">
<td>$10 <input type="text" name="amount_owed" id="amount_owed" value="10" style="display: none; width: 40px;" /></td>
<td>$20 <input type="text" name="amount_paid" id="amount_paid" value="20" style="display: none; width: 40px;" /></td>
<td>$30 <input type="text" name="check_cash_online" id="check_cash_online" value="30" style="display: none; width: 40px;" /></td>
<td><a href="javascript:void(0);" class="edit-row" title="row1">Edit</a></td>
</tr>
</tbody>
</table>
当我单击特定行的编辑时,我想删除前三个子单元格td
文本(即 10 美元、20 美元 ....),但元素除外。input
输入类型应在隐藏单元格文本后显示。请帮助我如何使用 jquery 脚本制作它。谢谢
我已经尝试了一些脚本来做到这一点,即
$(document).ready(function(){
$('.edit-row').click(function(){
var title = $(this).attr('title');
$('.'+title+' td').text('');
});
});
但是上面的脚本使单元格为空。