【发布时间】:2018-03-21 02:43:01
【问题描述】:
我有我的 html 表,它使用 jquery 将行附加到最后一行 例如
我想要什么
row1>> 刚刚发布
row2>> 1 分钟前发布
row3>> 2 分钟前发布
但它显示像
row1>> 2 分钟前发布
row2>> 1 分钟前发布
row3>>刚刚发布
<tbody>
<table align="center" style="width:auto" id="ex-table">
<tr id="tr">
<center><th>Date of join</th></center>
<center><th>name</th></center>
<center><th>designation</th></center>
<center><th>exprience</th></center>
<center><th>salary</th></center>
</tr>
</table>
</tbody>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
var database = firebase.database().ref().child('user');
database.on('value', function(snapshot){
if(snapshot.exists()){
var content = ' ';
snapshot.forEach(function(data){
var val = data.val();
content +='<tr>';
content += '<td>' + val.daeofjoin + '</td>';
content += '<td>' + val.name + '</td>';
content += '<td>' + val.designation + '</td>';
content += '<td>' + val.experience + '</td>';
content += '<td>' + val.salary + '</td>';
content += '</tr>';
});
$('#ex-table').append(content)
}
});
</script>
【问题讨论】:
标签: jquery html dynamic-tables