Reputation: 3289
I have a div in which i am displaying a message after login.
This is how i do it
options.waitingForOperator = 'Custom Message';
And then
$('#chat-box-msg').html(options.waitingForOperator);
Now i was trying to hide only the message
i.e (options.waitingForOperator)
after few second.
I read i can use settimeout, but not understanding how do i use iy to hide just the message
setTimeout(function () {
}, 3000);
I tried a lot but could not succeed.
Can anyone help me, because i am in learning phase of JQUERY
Update
if (chatId === null || chatId === '') {
if (nametext1 !== '') {
myHub.server.requestChat(msg);
$('#chat-box-msg').html(options.waitingForOperator);
} else {
alert(");
}
} else {
myHub.server.send(msg);
}
Upvotes: 0
Views: 98
Reputation: 3289
This is what i did to solve it.
if (nametext1 !== '') {
myHub.server.requestChat(msg);
$('#chat-box-msg').html('<div id=messagediv>' + options.waitingForOperator +'</div>');
setTimeout(function () {
$('#messagediv').hide();
}, 3000);
}
THanks a lot @Mr7-itsurdeveloper
Upvotes: 0
Reputation: 10007
you can use empty() which will just clear the inner text or content.
setTimeout(function () {
$('#chat-box-msg').empty();
}, 3000);
Upvotes: 0
Reputation: 1631
Don't use keywords
e.g options & dot (.) in options.waitingForOperator
try with .hide in setTimeout
$(document).ready(function() {
waitingForOperator ='Custom Message';
$('#chat-box-msg').html(waitingForOperator);
setTimeout(function () {
$('#chat-box-msg').hide(waitingForOperator);
}, 3000);
});
Upvotes: 1
Reputation: 3694
setTimeout(function () {
$('#chat-box-msg').empty();
}, 3000);
After three seconds, the above code will empty the #chat-box-msg
element.
Upvotes: 1