Update chatroom.HTML
This commit is contained in:
parent
2b04a655da
commit
0496be4e8b
1 changed files with 4 additions and 6 deletions
|
@ -34,9 +34,7 @@
|
|||
const messageInput = document.getElementById('message');
|
||||
const sendButton = document.getElementById('send');
|
||||
|
||||
sendButton.addEventListener('click', sendMessage);
|
||||
|
||||
function sendMessage() {
|
||||
sendButton.addEventListener('click', () => {
|
||||
const message = messageInput.value;
|
||||
if (message.trim() !== '') {
|
||||
const messageElement = document.createElement('div');
|
||||
|
@ -45,11 +43,11 @@
|
|||
chatbox.scrollTop = chatbox.scrollHeight; // Scroll to the bottom
|
||||
messageInput.value = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
messageInput.addEventListener('keyup', function(event) {
|
||||
messageInput.addEventListener('keyup', (event) => {
|
||||
if (event.key === 'Enter') {
|
||||
sendMessage();
|
||||
sendButton.click();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Reference in a new issue