I am trying to get the element for addEventListener from the html file using document.querySelector(‘???’). Currently I have document.querySelector(‘#prompt-2 form’) but that is not giving me the right EventListener to pass into my eventHandler function.
I am unsure what the querySelector is to get the form under this section.
const alertForm = document.querySelector('#prompt-2 form')
function alertMessage() {
msg = document.getElementById('#alert-text').value
alert(msg)
}
alertForm.addEventListener('submit', alertMessage);
<section id="prompt-2">
<form>
<p>Send an alert!</p>
<p>
<label for="alert-text">What do you want the alert to say?</label>
</p>
<p>
<input type="text" name="message" id="alert-text" />
</p>
<p>
<button type="submit">Send Alert!</button>
</p>
</form>
</section>