Setting up the form tag

First step, we need a form tag; this creates a form that's submittable by the user. This is exactly what we're going to use to submit our messages. And on this form tag we're going to add one attribute; it's the id attribute which lets us give this element a unique identifier, making it really easy to target with our JavaScript a bit later on:

<form id></form>
Remember, we're going to want to add a listener to this element. When the form gets submitted, we're going to want to do something in our JavaScript file. Notably what we're going to want to do is call socket.emit.

I'm going to set id equal to, inside quotes, message-form:

<form id="message-form"></form>

Now that we have our form tag complete we can add some ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.