$(document).ready(function() { var socket = io(); var downloadButton; socket.on('update visitors', function(visitors) { $('#visitors').text(visitors); }); socket.on('get book', function(url) { $(downloadButton).replaceWith('Download'); }); socket.on('remove book', function(bookId) { var book = $('#book_' + bookId); var modal = $('