jQuery-无法选择动态生成的内容
它仅对第一行有效,但对随后生成的行无效。 Jquery 这是HTMLjQuery-无法选择动态生成的内容,jquery,select,dynamic,Jquery,Select,Dynamic,它仅对第一行有效,但对随后生成的行无效。 Jquery 这是HTML <li class="receipt-item" id="row_1"> <ul class="browser-actions-receipt"> <li class="receipt-type"> <select name="ser_code[]" id="ser_code_1" class="ser_code">
<li class="receipt-item" id="row_1">
<ul class="browser-actions-receipt">
<li class="receipt-type">
<select name="ser_code[]" id="ser_code_1" class="ser_code">
<option selected disabled hidden value>Item Type</option>
@foreach ($options as $b => $a)
<option value="{{ $a['sch_code'] }}">{{ $a['eng_desc'] }}</option>
@endforeach
</select>
-
项目类型
@foreach($b=>a的选项)
{{$a['eng_desc']}
@endforeach
使用:
$(document).on('change','.ser_code',function () {
var text = $(this).val();
alert(text);
});
在Jquery中使用on()方法生成动态内容
可能重复的
$(document).on('change','.ser_code',function () {
var text = $(this).val();
alert(text);
});
$('.ser_code').on('change', function () {
var text = $(this).val();
alert(text);
});