My issue
what is the error in this code and if it have so how to debug
My code
// select the input text field using getElementById
const textInput = document.getElementById("textInput");
// select the submit button using getElementById
const submitButton = document.getElementById("submitButton");
// select the output div using getElementById
const outputDiv = document.getElementById("outputDiv");
// Add the event handler to the submitButton to get the data from the input field and add it to a textDiv which in turn is added to the output div.
// This allows you to add multiple data as we did in the last section.
submitButton.addEventListener("click",() => {
let inputText = textInput.value;
outputDiv.textContent = inputText;
});
Learning course: Web development using JavaScript
Problem Link: CodeChef: Practical coding for everyone