title: How to change div class when child node in Firebase Database is updated?
body: <p>my goal is to show content in a div element and then display exactly what writing in Firebase Database in accordance with two scenarios: accepted or Rejected. So, it is not working for some reason even when User is logged. </p>
  
  <p>How can it be fixed?</p>
  
  <p>Below is situation.</p>
  
  <p>For console error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'results' of null
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/zgctH.png" rel="nofollow noreferrer">index.esm.js:695 Uncaught TypeError: Cannot read property 'names' of null(anonymous function) @ (index):330(anonymous function) @ index.esm.js:4458mt @ index.esm.js:684t.raise @ index.esm.js:9720t.raiseQueuedEventsMatchingPredicate_ @ index.esm.js:9674t.raiseEventsForChangedPath @ index.esm.js:9658(anonymous function) @ index.esm.js:12676(anonymous function) @ index.esm.js:11791n.onDataMessage_ @ index.esm.js:12046t.onDataMessage_ @ index.esm.js:11331t.onPrimaryMessageReceived_ @ index.esm.js:11325(anonymous function) @ index.esm.js:11226t.appendFrame_ @ index.esm.js:10831t.handleIncomingFrame @ index.esm.js:10881mySock.onmessage @ index.esm.js:10778</a></p>
  
  <p>For accepted:</p>
  
  <pre><code>&lt;div id="one" class="hide"&gt;
     &lt;div id="stageone"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>For Rejected:</p>
  
  <pre><code>&lt;div id="two" class="hide"&gt;
    &lt;div id="stagetwo"&gt;&lt;/div&gt;
    &lt;div id="status"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>For database.rules.json</p>
  
  <pre><code>{"rules": {".read": true, ".write": true }}
  </code></pre>
  
  <p>For Javascript:</p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
      var okay = firebase.database().ref("users/" + uid + "/accepted");
      okay.on("value", function(snapshot) {
        var data = snapshot.val();
        $("#stageone").val(data.results);
        $("#one").removeClass('hide');
      });
      var nokay = firebase.database().ref("users/" + uid + "/rejected");
      nokay.on("value", function(snapshot) {
        var data = snapshot.val();
        $("#stagetwo").val(data.names);
        $("#status").val(data.results);
        $("#two").removeClass('hide');
      });
    &lt;/script&gt;
  </code></pre>
  
  <p>For Database Structure:</p>
  
  <p><a href="https://i.stack.imgur.com/RHqnl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RHqnl.png" alt="enter image description here"></a></p>