I have a 3 buttons in my HTML, one for each of three ski resorts. When a button is clicked I want to display the relevant information.
<div id="buttonParent">
<button id="btnStranda" type="button" value="0">Stranda</button>
<button id="btnFjellseter" type="button" value="1">Fjellseter</button>
<button id="btnOveroeye" type="button" value="2">Overøye</button>
</div>
I have this working, but the problem is I've made 3 separate functions which I believe could easily be made into 1.
If all the onclick
events go to the same function, how do I make the function detect which button was clicked so it will display the correct information?
function boot()
{
document.getElementById("btnStranda").onclick = infoStranda;
document.getElementById("btnOveroeye").onclick = infoOveroeye;
document.getElementById("btnFjellseter").onclick = infoFjellseter;
}