在选择添加按钮时如何增加jQuery内部添加功能中出现的值的显示选择框

问题描述

我放置了代码以连续添加选择框。我想取每个选择框的值并显示结果。下面的代码具有select_service_price的on-change函数,该函数静态地获取i的值,但是我想增加i的on-change函数的值,每次单击创建附加选择框的add函数时,i的值应更改。 >

$(document).on('click','.add',function(){   var html = '';   var i =
0;   i += 1;    html += '
<tr>
   ';    html += '
   <td>
      <select
         name="item_unit[]" onchange = "select_service_price('+i+')"
         class="form-control item_unit">
         <option value="">Select
            Unit
         </option>
         <?PHP echo fill_unit_select_Box($connect);
            ?>
      </select>
   </td>
   ';   //i += 1;    html += '
   <td><button type="button"
      name="remove" class="btn btn-danger btn-sm remove">
      <span
         class="glyphicon glyphicon-minus"></span></button>
   </td>
</tr>
';  
$('#item_table').append(html);  });  

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)