我想在 DropBox 中添加两个选项
$("#payment_method_1").append(new Option("Credit", "7"));
$("#payment_method_1").append(new Option("Debit", "6"));
当我实现该代码时,它会完美地附加,但问题是它附加了很多次而不是一次
<select name="payment_method_1" id="payment_method_1" class="paysome" style="opacity: 0;">
<option value="1" selected="selected">Cash</option>
<option value="2">Credit Card</option>
<option value="3">Western Union</option>
<option value="4">Cheque</option>
<option value="8">Bank</option>
<option value="7">Credit</option>
<option value="6">Debit</option>
<option value="7">Credit</option>
<option value="6">Debit</option>
<option value="7">Credit</option>
<option value="6">Debit</option>
<option value="7">Credit</option>
<option value="6">Debit</option>
</select>
这是我的循环
$('.paysome').each(function(index, element) {
$("#payment_method_"+index).append(new Option("Credit", "7"));
$("#payment_method_"+index).append(new Option("Debit", "6"));
});
提前致谢