我已将tbody的id声明为table_body。我还插入了jquery代码。在我的js文件中包含javascript和jquery,而不是纯javascipt。所以它影响了结果?
var firebaseRef = firebase.database().ref('facility');
var query = firebaseRef.orderByKey();
query.on("child_added", function(snapshot) {
var tb_name = snapshot.child('schedulename').val();
var tb_time = snapshot.child('timesession').val();
var tb_fees = snapshot.child('fees').val();
console.log(snapshot.val());
$("#table_body").append("<td><tr>" + tb_name + "</tr><tr>" + tb_time + "</tr><tr>" + tb_fees + "</tr></td>");
});
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<div style="display: flex; justify-content: flex-end">
<table border="2" style="color:#f2f2f2">
<thead>
<tr>
<td>Schedule</td>
<td>Time Session</td>
<td>Fees</td>
</tr>
</thead>
<tbody id="table_body"></tbody>
<table>
</div>