Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery-无法选择动态生成的内容_Jquery_Select_Dynamic - Fatal编程技术网

jQuery-无法选择动态生成的内容

jQuery-无法选择动态生成的内容,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">

它仅对第一行有效,但对随后生成的行无效。 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">
                <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);
        });