$(document).on('change', ".checkboxtd", function() {
var inden_id = $(this).parent().next().next().next().next().next().next().next().next().next().next().next().children().val();
alert(inden_id);
if ($(this).is(":checked")) {
alert('checked');
} else {
alert('Un checked');
$('#indent_detailid').val('');
//$('#indent_detailid').val('');
}
});
HTML CODE:
$('.recptdt').append('<tr><td><input type="checkbox" class = "checkboxtd" name = "check[]" style="margin-left:15%" value="O"></td><td>' + i + '</td><td>' + b.item_type + '</td><td>' + b.item_name + '</td><td>' + b.model_no + '</td><td class = "serialno" >' + b.serial_no + '</td><td>' + b.unit + '</td><td style = "display:none"><input class = "form-control" type = "text" name = "" readonly id = "issuqantity"></td><td style = "display:none ">' + b.receipt_qty + '</td><td style = "display:none"><input class = "form-control" type = "text" value = ' + b.indent_issue_id + ' name = "issu_id[]" id = "issu_id"></td><td style = "display:none"><input type = "text" id = "stock_idno" name = "stock_idno[]" value ="' + b.det_stock_id + '"><td style = "display:"><input class = "form-control" type = "text" value = ' + b.indent_detail_id2 + ' name = "indent_detailid2[]" id = "indent_detailid"></td><td style = ""><input class = "form-control issuqantity" type = "text" value = ' + b.issue_qty + ' name = "issuqantity[]" readonly = "readonly" id = "issuqantity"></td><td><input type = "text" value = "" name = "recqty[]" class = "form-control booksqty" onkeypress="return isNumberKey(event);" id = "req_val"/></td><td style = "display:"><input type = "text" name = "det1_indent_detail_id1[]" value = "' + b.indent_detail_id1 + '"></td><td><input type = "text" value = "' + b.item_id + '" class = "itm_id" name = "itm_id[]"/></td></tr>');
如何清空$('#indent_detailid').val('');
警报正常工作。仍然无法清空动态创建的文本框值... !!
答案 0 :(得分:0)
你重复id,所以将i值添加到id 像
<input class = "form-control" type = "text" value = ' + b.indent_detail_id2 + ' name = "indent_detailid2[]" id = "indent_detailid"+i>
获取并重置
var i = $(this).parent().next().val();
$('#indent_detailid'+ i).val('');