gpt4 book ai didi

javascript - Jquery 模态保留以前的值

转载 作者:行者123 更新时间:2023-12-02 15:34:27 24 4
gpt4 key购买 nike

我正在使用 jQuery 模态来动态显示一些表数据,现在的问题是,在每次迭代中,创建的数据都会附加到模态中,但下次它保存前一行,如何摆脱它我正在发布我的代码

<div class="modal fade" id="event-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header-avaliability">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">Avilable Interviews</h4>
</div>
<div class="modal-body">
<table class="myTable">
<tr>
<th width="10%">Company Name</th>
<th width="10%">Interviewer</th>
<th width="10%">Subject</th>
<th width="10%">Timing</th>
<th width="10%">Consultant Name </th>
<th width="10%">Candidate Name </th>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->

javascript操作

jQuery.getJSON(url+"&date=" +date.format()+"&consultantID="+consultantID+"&teamName="+teamName+"&type="+type, function(data)  {

var $formrow =0 ;
var arr =0;
var arr1 =0;
var arr2 =0 ;
var arr3 = 0;
for(var z=0; z<data.applicationArray.length;z++){
applicationArray = data.applicationArray[z].split("##%%$$");

arr = applicationArray.slice();
arr1 = arr[0].slice();
arr2 = arr[1].slice();
arr3 = arr[2].slice();
arr4 = arr[3].slice();
arr5 = arr[4].slice();
arr6 = arr[5].slice();

$formrow = '<tr><td>'+arr1+'</td><td>'+arr2+'</td><td>'+arr3+'</td><td>'+arr4+'</td><td>'+arr5+'</td><td>'+arr6+'</td></tr>';
$('.myTable').append($formrow);
}
$('#event-modal').modal('show');

});

模态保持以前的值,我正在使用 $('#event-modal').html('') 但不工作,请帮忙。

最佳答案

jQuery.getJSON(url+"&date=" +date.format()+"&consultantID="+consultantID+"&teamName="+teamName+"&type="+type, function(data)  {

var $formrow =0 ;
var arr =0;
var arr1 =0;
var arr2 =0 ;
var arr3 = 0;
$(".myTable").html('<tr> <th width="10%">Company Name</th> <th width="10%">Interviewer</th> <th width="10%">Subject</th> <th width="10%">Timing</th> <th width="10%">Consultant Name </th> <th width="10%">Candidate Name </th> </tr>');
for(var z=0; z<data.applicationArray.length;z++){
applicationArray = data.applicationArray[z].split("##%%$$");

arr = applicationArray.slice();
arr1 = arr[0].slice();
arr2 = arr[1].slice();
arr3 = arr[2].slice();
arr4 = arr[3].slice();
arr5 = arr[4].slice();
arr6 = arr[5].slice();

$formrow = '<tr><td>'+arr1+'</td><td>'+arr2+'</td><td>'+arr3+'</td><td>'+arr4+'</td><td>'+arr5+'</td><td>'+arr6+'</td></tr>';
$('.myTable').append($formrow);
}
$('#event-modal').modal('show');

});

这会起作用。添加$(".myTable").html('<tr> <th width="10%">Company Name</th> <th width="10%">Interviewer</th> <th width="10%">Subject</th> <th width="10%">Timing</th> <th width="10%">Consultant Name </th> <th width="10%">Candidate Name </th> </tr>');这样.myTable每次刷新。

关于javascript - Jquery 模态保留以前的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33057666/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com