Using jQuery to create element in index.js

The first thing we're going to do is create a list item, and we're going to do this once again using jQuery. We're going to make a variable, this variable is going to be called li, and we're going to go ahead and use jQuery slightly differently:

socket.on('newMessage', function (message) {  console.log('newMessage', message);  var li = jQuery();});

Rather than using jQuery to select an element, we're going to use jQuery to create an element, then we can modify that element and add it into the markup, making it visible. Inside quotes, we're going to open and close an li tag, just like we would inside index.html:

socket.on('newMessage', function (message) {  console.log('newMessage', message); var li ...

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.