S
S
Space2014-03-14 13:58:05
JavaScript
Space, 2014-03-14 13:58:05

How to replace a div with another div?

Hello. Here I am sending data by socket that a new client has arrived with a div, indicated id (each client has its own).

client.broadcast.emit('clientNew', {clientNew : '<div id=' + clientId + '>Пришел новый Вася!</div>'});

And if the client left, then I send the following data:
io.sockets.emit('clientNew', {clientNew : '<div id=' + clientId + '>Вася уплыл!</div>'});


Of course, if the user is logged in, a div is added to the site, and if he leaves, then a div is added as well. How to make one div replace another div? For it specified id. How to do? Tell. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Lobanov, 2014-03-14
@ruslite

So why do you need to replace the div? Change the id of the div and its html

$('#id1').attr('id','id2')
$('#id2').html('Новый контент внутри дива')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question