get value input inside append
hi everyone, i've some problem when using append
I have no idea to call the value input and dataset in the append
HTML
- <div class="row form-group">
- <div class="col-md-12">
- <select class="form-control category_id" name="jumlah"
- id="entity"
- required>
- <option value="1" selected="tr">---- 1 Data ----
- </option>
- @for($i=2;$i<=10;$i++)
- <option value="{{$i}}">---- {{$i}} Data ----
- </option>
- @endfor
- </select>
- </div>
- </div>
- <div id="loop">
- <div class="row form-group has-feedback">
- <div class="col-md-12">
- <input placeholder="Type Name"
- data-tabe="name1"
- class="form-control name1"
- id="name[]"
- name="name[]" required autofocus>
- </div>
- </div>
- </div>
//Jquery
- <script>
- $(document).ready(function () {
- $(document).on('change', '#entity', function () {
- var fill1 = '';
- var valu = $(this).val();
- fill1 = '';
- for (var i = 1; i <= valu; i++) {
- fill1 += '<div class="row form-group has-feedback">\n' +
- ' <div class="col-md-12">\n' +
- ' <input placeholder="Type Name"\n' +
- ' data-tabe="name'+i+'"\n' +
- ' class="form-control name'+i+'"\n' +
- ' id="name[]"\n' +
- ' name="name[]" required autofocus>\n' +
- '\n' +
- ' </div>';
- }
- $('#loop').empty().append(fill1);
- });
- $('#loop').html();
- $('#loop .name2').on('input', function (e) {
- console.log(e.delegateTarget.dataset.tabe);
- console.log(e.delegateTarget.value);
- });
- });
- </script>
any advice?
thanks