This is what I am trying to achieve: If a input image is clicked, and the input image matches word (referenced in array) run a previously ran function again.
I've messed around with the code but can not seem to figure out why it's not working. Here's part of what I have:
This is a snippet of my random word array with referenced pairings
var randomwordz = [
{word: 'Orange Juice', image: 'orange.gif'},
.....//etc.
{word: 'Pasta', image: 'pasta.gif'}];
randomwordz[0].word
randomwordz[0].image
.....//etc.
randomwordz[8].word
randomwordz[8].image
var randoms = randomwordz[Math.floor(Math.random()*randomwordz.length)];
document.getElementById('randomwords').innerHTML = randoms.word;
document.getElementById('randomimages').src= randoms.image;
heres part of my code where I am trying to run a function once input image is clicked that is equal to its word
function wordMatchImage(){
if(document.getElementById('randomimages').clicked == true)
{
if ('randoms.word' == 'randoms.image'){
backgroundGone();}
}
}
I'm new enough to javascript so please excuse that lack of knowledge and terminology :P
Aucun commentaire:
Enregistrer un commentaire