Created
March 12, 2021 06:36
-
-
Save bogoreh/25affcab328d64100ed0a0e566bfce5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Challenge: jQuery trivia quiz</title> | |
<style> | |
#result { | |
background: rgb(255, 246, 204); | |
border: 2px dotted gold; | |
font-size: 24px; | |
height: 60px; | |
margin-top: 10px; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>jQuery Quiz</h1> | |
<form id="trivia-form"> | |
<label> | |
Who invented jQuery?<br> | |
<select id="trivia-answer"> | |
<option value="eich">Brendan Eich</option> | |
<option value="resig">John Resig</option> | |
<option value="rossum">Guido van Rossum</option> | |
<option value="berners">Tim Berners-Lee</option> | |
</select> | |
</label> <br> | |
<button type="submit">Check Answer</button> | |
</form> | |
<div id="result"></div> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> | |
<script> | |
$("#trivia-form").on("submit", function(event) { | |
event.preventDefault(); | |
var answer = $("#trivia-answer").val(); | |
if(answer === "resig") { | |
$("#result").text("You're right!"); | |
} else { | |
$("#result").text("You're right!"); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment