特定行的 Jquery html()

我已经使用类型(选择)、名称(文本)、单位(选择)创建了动态行,我正在为更改类型的选择编写代码。但是,当我从类型字段中更改值时,它已将值加载到当前行名称字段中,并将选项动态加载到当前单元选择字段中,将值加载到活动行中工作正常,但将选项加载到选择单元中则不行。


我的代码如下


$(document).on('change', '.raw', function () {

    // var r = this.val();

    if ($(this).val() != 0) {

    var t = $(this).parents('tr').find(".raw :selected").text();

    $(this).parents('tr').find(".name").val(t);

我需要帮助的地方如下


$(this).parents('tr').find(".amount").html(data); -> here i need help

// $(".amount").html(data); ->this working fine but change all the select value

提前致谢。这是我的表的完整编码


<table id="addingtable" class="table table-bordered">

<tr>

  <th>Raw Master</th>

  <th>Name</th>

  <th>Display</th>

  <th>Value</th>

  <th>Unit</th>

  <th>Delete</th>

</tr>

<tr>

  <td><select name='rawmaster[]'  class = 'form-control raw' required><option>Select</option><?php echo rawmaster_item($conn,$type);  ?><option value="0">None</option></select></td>

  <td><input type='text' name='name[]'  placeholder="Name" class = 'form-control name' required /></td>

  <td><select name='des[]' class = 'form-control' required><option>Select</option><option Value = 'y'>Yes</option><option Value = 'n'>No</option></select></td>

  <td><input type='text' name='value[]' placeholder="Value" class = 'form-control' required /></td>

   <td><select name='amount[]' class = 'form-control amount' required><option>Select</option><?php echo $output2;  ?></select></td>

  <td><button type='button' class='btn btn-icon btn-danger remove'><i class='feather icon-trash-2'></i></button></td>

</tr>


收到一只叮咚
浏览 96回答 1
1回答

ABOUTYOU

我可能错了,但我认为您需要在 ajax 请求上设置上下文,否则this将引用不同的上下文(回调),添加context:this如下:$.ajax({&nbsp; &nbsp; url:"plandetails_getunit.php",&nbsp; &nbsp; method:"POST",&nbsp; &nbsp; data:"id="+r,&nbsp; &nbsp; context:this,&nbsp; &nbsp; success:function(data)&nbsp; &nbsp; {
打开App,查看更多内容
随时随地看视频慕课网APP