0

It works only on the first row, but not on the subsequently generated rows. Jquery.

$(".ser_code").change(function () {
    var text = $(this).val();
    alert(text);
});

This is the 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>
Sen
  • 111
  • 3
  • 17
  • 2
    possible duplicate of [Event binding on dynamically created elements?](http://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements) – Barmar Feb 03 '14 at 04:12

2 Answers2

1

use .on() :

$(document).on('change','.ser_code',function () {
var text = $(this).val();
alert(text);
});
Milind Anantwar
  • 77,788
  • 22
  • 86
  • 114
0

Use on() method in Jquery for dynamic content generation.

$('.ser_code').on('change', function () {
    var text = $(this).val();
    alert(text);
    });
Sudharsan S
  • 14,830
  • 3
  • 27
  • 47