Create script.js
Browse files
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>
|