Javascript - Program the Web
This course covers the basics of programming in Javascript. Work your way through the videos/articles and I'll teach you everything you need to know to make your website more responsive!

Building A Messaging App

Lesson 15
Author : 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.jsCopy
var 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 = ""; });