Answer the question
In order to leave comments, you need to log in
Node.JS Why doesn't the script work on display none?
Hello. I have some code that is supposed to send two and text to the server, then the server sends them back, after which I would like one of them to disappear (display:none or .hide() ), but that doesn't happen, why? There are no errors in the console, and the text is displayed perfectly.
client
usernameWindw = $(".usernameWindow");
chatWindw = $(".chatWindow");
$nickname = $("#nick_Name").val();
//ОТПРАВКА НА СЕРВЕР
function requestSubmitNickname() {
socket.emit('requestSetNickName', chatWindw, usernameWindw, $nickname);
}
//ПОЛУЧЕНИЕ С СЕРВЕРА
socket.on('setNickName', function(chatWin, userWin, username_text){
$username = username_text;
$(userWin).hide();
$(chatWin).show();
console.log(username_text);
});
//ОТПРАВКА КЛИЕНТУ
socket.on('requestSetNickName', function(chatWind, usernameWind, nickname){
io.sockets.emit('setNickName', chatWind, usernameWind, nickname);
});
Answer the question
In order to leave comments, you need to log in
Do you send items?
And what should you get in return? what's in userWin and chatWin? If layout, then it simply creates jQuery instances and hide / show them, and since they are not in the DOM tree, you don’t see anything. If id or class, then
$('.'+userWin).hide(); or $('#'+userWin).hide();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question