Rendering the newLocation template

The first thing we're going to do is comment out the code we no longer need; that's everything but the variable formattedTime:

socket.on('newLocationMessage', function (message) {  var formattedTime = moment(message.createAt).format('h:mm a');  // var li = jQuery('<li></li>');  // var a = jQuery('<a target="_blank">My current location</a>');  //   // li.text(`${message.from} ${formattedTime}: `);  // a.attr('href', message.url);  // li.append(a);  // jQuery('#message').append(li);});

Next up we're going to go ahead and grab the template from the HTML by making a variable called template, and we're going to use jQuery to select it by ID. Right inside the quotes, we'll add our selector. We want to select by ID so ...

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.