为什么我无法在html中显示firebase数据库的结果

时间:2018-02-26 15:44:58

标签: javascript jquery html firebase

console.log result

我已将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>

0 个答案:

没有答案