Add table row in jQuery

前端 未结 30 2338
既然无缘
既然无缘 2020-11-21 05:40

What is the best method in jQuery to add an additional row to a table as the last row?

Is this acceptable?

$(\'#myTable\').append(\'

        
30条回答
  •  后悔当初
    2020-11-21 06:23

    I Guess i have done in my project , here it is:

    html

    <%= form_for (@replication) do |f| %>
    <%= f.label :SR_NO %> <%= f.text_field :sr_no , :id => "txt_RegionName" %>
    <%= f.label :Particular %> <%= f.text_area :particular , :id => "txt_Region" %>
    <%= f.label :Unit %> <%= f.text_field :unit ,:id => "txt_Regio" %>
    <%= f.label :Required_Quantity %> <%= f.text_field :quantity ,:id => "txt_Regi" %>
    <% end %>
    SR_NO Item Name Particular Cost

    js

    $(document).ready(function() {     
        $('#submit').prop('disabled', true);
        $('#btn_AddToList').click(function () {
         $('#submit').prop('disabled', true);
        var val = $('#txt_RegionName').val();
        var val2 = $('#txt_Region').val();
        var val3 = $('#txt_Regio').val();
        var val4 = $('#txt_Regi').val();
        $('#lst_Regions').append('' + val + '' + '' + val2 + '' + '' + val3 + '' + '' + val4 + '');
        $('#txt_RegionName').val('').focus();
        $('#txt_Region').val('');
            $('#txt_Regio').val('');
            $('#txt_Regi').val('');
        $('#btn_AddToList1').click(function () {
             $('#submit').prop('disabled', false).addclass('btn btn-warning');
        });
          });
    });
    

提交回复
热议问题