Skip to content

Instantly share code, notes, and snippets.

Created Feb 18, 2019
What would you like to do?
Building A (Simple) Group Chat Using Node.js
<!DOCTYPE html>
<title>Simple Group Chat on Node.js</title>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
form { background: #fff; padding: 3px; position: fixed; bottom: 0; width: 100%; border-color: #000; border-top-style: solid; border-top-width: 1px;}
form input { border-style: solid; border-width: 1px; padding: 10px; width: 85%; margin-right: .5%; }
form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; margin-left: 2%; }
#messages { list-style-type: none; margin: 0; padding: 0; }
#messages li { padding: 5px 10px; }
#messages li:nth-child(odd) { background: #eee; }
<script src=""></script>
<ul id="messages"></ul>
<form action="/" method="POST" id="chatForm">
<input id="txt" autocomplete="off" autofocus="on" placeholder="type your message here..." /><button>Send</button>
// submit text message without reload/refresh the page
e.preventDefault(); // prevents page reloading
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment