从html动态创建的表中追加和删除数据

时间:2016-06-20 07:43:01

标签: javascript jquery html

无法删除我在按钮上填充的动态数据单击到html表。我想根据包含要显示的数据的变量一次又一次地更新这些表数据。



$("#go").click(function() {
		
    $("#orderGraph").show();
    $("#profitGraph").show();
    $("#report").show();

    $("#go").on('click',function(){
        $("#datatable").remove();
    });

    response = $.parseJSON(response);

    $(function () {
        $.each(response, function (i, item) {
            $('<tr>').append(
            $('<td>').text(item.orderId),
            $('<td>').text(item.purchaseId),
            $('<td>').text(item.shipmentId),
            $('<td>').text(item.useCase),
            $('<td>').text(item.orderCondition),
            $('<td>').text(item.orderType)).appendTo('#datatable');
        }); 
    });
	

    $("#datatable tbody tr").hide();
    $("#datatable tr:contains("+multicompanyUseCaseData+")").show();

});
&#13;
&#13;
&#13;

&#13;
&#13;
<button id="go" type="submit" value="Submit" >Go</button>

                 <div class="x_content">
                    <table id="datatable" class="table table-striped table-bordered">
                      <thead>
    <tr>
        <th>Order Id</th>
        <th>Shipment Id</th>
        <th>Purchase Id</th>
		<th>Use Case</th>
		<th>Order Condition</th>
		<th>Order Type</th>
    </tr>
                      </thead>


                      <tbody>

                      </tbody>
                    </table>
                  </div>
&#13;
&#13;
&#13;

0 个答案:

没有答案