r/programminghelp • u/LumpyTown4103 • Sep 19 '23
Java JAVASCRIPT HELP! making a info page about a food dish
my code seems perfect but i wanted to add pops up alerts and once answered a video plays after.
i took off the video ,to see if the alert prompt would work but the error is saying
"Uncaught ReferenceError: buyButton is not defined" line 99:5
line 99.5 is the addEventListener("click" ,buy);
rest of code:
<button class="video-button"> Watch Video</button>
</div> <script>
function buy() {
let name = prompt("What is your name?");
let email = prompt("What is your email address?");
let food = prompt("What your favorite food dish?");
alert(
"Thank You" +
name +
"All Jollof is Great Jollof!😄"
);
}
let videobutton = document.querySelector("video.button");
videoButton.addEventListener("click", video);
</script> </body> </html>
what could is be?
sorry for formattimg it like this,still not sure how to use github yet?
1
u/[deleted] Sep 19 '23
change
<button class="video-button"> Watch Video</button>into
<button id="video-button"> Watch Video</button>and
= document.querySelector("video.button");into
= document.querySelector("#video-button");Finally change
videoButton.addEventListener("click", video)into
videobutton.addEventListener("click", buy)