[英]How to set value in p tag using jq?
I am trying to search bank name onkeyup and want to put result in p tag but it's not happening. 我正在尝试搜索银行名称onkeyup,并希望将结果放在p标记中,但没有发生。 can help me anyone? 能帮助我吗?
this is jq : //search bank name 这是jq://搜索银行名称
$('input[name^="acc_voucher_bank[]"]').live('keyup',function(){
var acc_voucher_bank=$(this).val();
$(this).closest('tr').find('p.bankNameResult').show();
$.post("../accounting_model/cash_receive_daily_date_wise.php",{
acc_voucher_bank:acc_voucher_bank,
rand:Math.random()
},function(data){
$(this).closest('tr').find('p.bankNameResult').html(data);
})
})
html code : html代码:
<table width="100%" id="myTable">
<tr class="tr_view">
<td style="width:25%;">Bank Name</td>
<td style="width:30%;">Branch Name</td>
<td style="width:15%;">A/C. No</td>
<td style="width:15%;">Amount</td>
<td style="width:15%;">Action</td>
</tr>
<tr class="bg1" style="text-align:center;">
<td>
<input type="text" style="width:200px;" name="acc_voucher_bank[]" id="" placeholder="Bank Name" />
<p id="bankNameResult" class="bankNameResult" name="bankNameResult[]" style="position:absolute; margin:0px;"></p>
<input type="hidden" name="bank_id[]" id="" />
</td>
<td>
<input type="text" style="width:270px;" name="acc_voucher_branch[]" id="" placeholder="Branch Name" />
<p id="bankBranchNameResult" class="bankBranchNameResult" name="bankBranchNameResult[]" style="position:absolute; margin:0px;"></p>
<input type="hidden" name="bank_branch_id[]" id="" />
</td>
<td>
<input type="text" style="width:130px;" name="acc_bank_account_number[]" id="" placeholder="A/C No" />
<p id="bankAccountResult" class="bankAccountResult" name="bankAccountResult[]" style="position:absolute; margin:0px;"></p>
<input type="hidden" name="bank_account_no[]" id="" />
</td>
<td><input type="text" style="width:130px;" name='bank_amount[]' id="" placeholder="Amount" /></td>
<td><input type="button" value="+" class="addTr" /></td>
</tr>
</table>
That's because this
inside the $.post
callback function is a jQuery XHR object. 这是因为this
里面$.post
回调函数是一个jQuery XHR对象。 You can assign the element which you want to change to another variable, so it won't get changed inside $.post
callback: 您可以将要更改的元素分配给另一个变量,这样它就不会在$.post
回调中被更改:
$('input[name^="acc_voucher_bank[]"]').live('keyup',function(){
var acc_voucher_bank=$(this).val();
$element = $(this).closest('tr').find('p.bankNameResult');
$element.show();
$.post("../accounting_model/cash_receive_daily_date_wise.php",{
acc_voucher_bank:acc_voucher_bank,
rand:Math.random()
},function(data){
$element.html(data);
})
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.