I'm able to hide the 'tr' when 'Remove' is clicked. with the following code.
$("a#minus").bind("click", function(e){
$(this).closest('tr').hide();
});
But I also want to clear the content of the 2 text boxes (id of the textbox's are dynamic [frm_Expense_expensesVO___strAmount and frm_Expense_expensesVO___memo] here '*' goes from 1 to infinity). Please help. Thanks
<table>
<tr>
<td>
Amount
</td>
<td>
Memo
</td>
<td>
</td>
</tr>
<tr>
<td>
<input type="text" name="expensesVO[0].strAmount" value="2.30" id="frm_Expense_expensesVO_0__strAmount"/>
</td>
<td>
<input type="text" name="expensesVO[0].memo" value="Five" id="frm_Expense_expensesVO_0__memo"/>
</td>
<td>
<a id="minus" href="#">Remove</a>
</td>
</tr>
<tr>
<td>
<input type="text" name="expensesVO[1].strAmount" value="3.45" id="frm_Expense_expensesVO_1__strAmount"/>
</td>
<td>
<input type="text" name="expensesVO[1].memo" value="Six" id="frm_Expense_expensesVO_1__memo"/>
</td>
<td>
<a id="minus" href="#">Remove</a>
</td>
</tr>
<tr>
<td>
<input type="text" name="expensesVO[2].strAmount" value="" id="frm_Expense_expensesVO_2__strAmount"/>
</td>
<td>
<input type="text" name="expensesVO[2].memo" value="" id="frm_Expense_expensesVO_2__memo"/>
</td>
<td>
<input type="submit" id="frm_Expense_ExpenseAdd_plus" name="action:ExpenseAdd_plus" value="+"/>
</td>
</tr>
<tr>
<td>
<label id="frm_Expense_transactionVO_amount">5.75</label>
</td>
<td align="right">
<input type="submit" id="frm_Expense_Cancel" name="action:ExpenseAdd_cancel" value="Cancel"/>
</td>
<td align="left">
<input type="submit" id="frm_Expense_Save" name="action:ExpenseAdd_save" value="Save"/>
</td>
</tr>
Set the value NULL of input field using document. getElementById('myInput'). value = ”
find('input:text'). val(''); $('input:checkbox'). removeAttr('checked'); }); One will clear all text inputs.
$("a#minus").bind("click", function(e){
$(this).closest('tr').hide().find('input:text').val('');
});
Note: Also see darmen's answer on why the selector a#minus
will not work as desired.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With