here is my html code
<p id="b1" onclick="clickFunction(this)" >+</p>
<p id="b2" onclick="clickFunction(this)">+</p>
<p id="b3" onclick="clickFunction(this)">+</p>
<p id="b4" onclick="clickFunction(this)">+</p>
<p id="b5" onclick="clickFunction(this)">+</p>
<p id="b6" onclick="clickFunction(this)">+</p>
<p id="b7" onclick="clickFunction(this)">+</p>
<p id="b8" onclick="clickFunction(this)">+</p>
<p id="b9" onclick="clickFunction(this)">+</p>
here is my javascript code
var status = [2, 2, 2, 2, 2, 2, 2, 2, 2];
var gameStatus = {
b1: 2,
b2: 2,
b3: 2,
b4: 2,
b5: 2,
b6: 2,
b7: 2,
b8: 2,
b9: 2
}
function clickFunction(element) {
var ids = element.id
document.write(gameStatus.ids) //but it returns undefined
};
Now I want to take the id and use that id to call the object in the gameStatus gameStatus.id is giving me undefined.
I tried all the methods like converting it to number or string but nothing works.
Converting it to number give me Nan and converting it to sting and then using it gives me undefined. Please help me