I'm a complete newbie to front end web development. I'm trying to design a simple game where I have a set of 3 images (bearing questions). Each image has 2 buttons underneath it marked 'Yes' and 'No'. The user needs to click on the correct button under each image to answer the question.
The correct answer for image 1 is 'No', for image 2 is 'No' and for image 3 is 'Yes'.
Below is my relevant HTML:
<div class="buttoncontainer">
<button id="submit-btn1" onclick="subtractone()">Yes!</button>
<button id="submit-btn2" onclick="addone()">No!</button>
</div>
<div class="buttoncontainer">
<button id="submit-btn3" onclick="subtractone()">Yes!</button>
<button id="submit-btn4" onclick="addone()">No!</button>
</div>
<div class="buttoncontainer">
<button id="submit-btn5" onclick="subtractone()">Yes!</button>
<button id="submit-btn6" onclick="addone()">No!</button>
</div>
<div class="scoresheet">
<p id="resultMessage"></p>
</div>
The idea is to display the score within scoresheet and display text based on the score.
Below is the JQuery I have so far managed. I would be very grateful for any assistance.
$(document).ready(function() {
var finalScore = 0;
console.log(finalScore);
$("#resultMessage").html("<p>" + finalScore + "</p>");
function subtractone(finalScore) {
finalScore = finalScore - 1;
$("#resultMessage").html("<p>" + finalScore + "</p>");
}
function addone(finalScore) {
finalScore = finalScore + 1;
$("#resultMessage").html("<p>" + finalScore + "</p>");
}
});