简体   繁体   中英

addeventlistener function not working as expected

I am not able to see the data in firebase database after giving the input through UI. Can anyone please help?

<body>
  <input id="username" type="text" placeholder="Name"><br/>
  <input id="text" type="text" placeholder="Message"><br/>
  <button id="post">Send</button><br/>
  <div id="results"></div>
  <script>
    var myFirebase = new Firebase('https://webchat-a778f.firebaseio.com/');
    var usernameInput = document.getElementByID("username");
    var textInput = document.getElementByID("text");
    var postButton = document.getElementByID("post");

    postButton.addEventListener("click", function() {
      myFirebase.push(usernameInput + " says: " + textInput);
      textInput.value = "";
    },false);

You have a syntax error

It should be

document.getElementById

The last d is in lowercase

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM