AilexGPT commited on
Commit
9122591
·
1 Parent(s): 394c011

Create script.js

Browse files
Files changed (1) hide show
  1. script.js +22 -0
script.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script>
2
+ const chatbotMessages = document.querySelector('.chatbot-messages');
3
+ const chatbotInput = document.querySelector('.chatbot-input input');
4
+ const chatbotButton = document.querySelector('.chatbot-input button');
5
+
6
+ chatbotButton.addEventListener('click', () => {
7
+ const userMessage = chatbotInput.value;
8
+ const botMessage = 'Hey alles fresh?';
9
+ const message = `
10
+ <div class="chatbot-message">
11
+ <span class="user">You:</span>
12
+ <span>${userMessage}</span>
13
+ </div>
14
+ <div class="chatbot-message">
15
+ <span class="bot">Bot:</span>
16
+ <span>${botMessage}</span>
17
+ </div>
18
+ `;
19
+ chatbotMessages.insertAdjacentHTML('beforeend', message);
20
+ chatbotInput.value = '';
21
+ });
22
+ </script>