So i want too start off by saying I am very new at web development, specifically javascript. I'm trying to build a simple program where you check certain items from a list of certain ingredients from a video game, and you are then told which recipes you can make. I am struggling with getting the text to appear in the html when a box is checked.
This is my html for one of the ingredients that make a recipe from just the one item:
<div>
<input type="checkbox" id="egg" name="egg">
<label for="egg">Egg</label>
</div>
This is the javascript I have trying to make the recipe appear under the checkboxes in a paragraph with the id being "make":
if (document.getElementById("egg").checked === true) {
document.getElementById("make").innerHTML = "You can make a fried egg with egg!";
}
Aucun commentaire:
Enregistrer un commentaire