I am currently building a small text adventure, however I have multiple span
elements with the same id.
This way, I use the document.getElementById('id').onclick
in JavaScript, they're all affected. Or so I thought.
Apparently, this only works with the first span.
How can I make this work?
function examineArea() {
document.getElementById('game_text').innerHTML='You are sitting at the end of a long table. A feast is laid, and the <span id="baronBattenhillButton">Baron</span> tells you to eat as much as you want, as will he.<br/>There are mounted heads hanging from the wall. You wonder if the <span id="baronBattenhillButton">Baron</span> had hunted them himself.<br/><br/><br/>Sitting on the other side of the table is <span id="baronBattenhillButton">Baron Battenhill</span> himself. There are <span id="baronsGuardButton"/>guards</span> on both his right and his left side.<br/>The <span id="baronsGuardButton"/>Baron</span> has a worried look on his face.';
document.getElementById('baronBattenhillButton').onclick=examineBaronBattenhill;
}