Building A Messaging App
Lesson 15Author : GOUP
Last Updated : September, 2020
Code
index.htmlCopy<ul id="messages"></ul> <input id="textbox" type="text"> <button id="button">Send</button> <script src="script.js"></script>
script.jsCopyvar messages = document.getElementById("messages"); var textbox = document.getElementById("textbox"); var button = document.getElementById("button"); button.addEventListener("click", function(){ var newMessage = document.createElement("li"); newMessage.innerHTML = textbox.value; messages.appendChild(newMessage); textbox.value = ""; });