Adding the selector element to index.js

Inside index.js we're going to add that exact same selector near the bottom, jQuery, calling it with our selector #message-form. Now we're going to add an event listener, and the event listener is going to look pretty similar to our Socket.io event listeners. We are going to be calling on, and we are going to be providing, those two arguments, the event name inside quotes, submit, and a function, which is going to fire when a user tries to submit the form:

jQuery('#message-form').on('submit', function(){  });

Now unlike our Socket.io event listeners, we are going to get one argument in the function, an e event argument, and we are going to need to access this. We're going to need to access this event ...

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.