javascript - How to Make If statement for a specific Image source? -


i have line in program (run in dreamweaver) following:

function go() { if((document.test.test1.src == document.test.test2.src && document.test.test2.src == document.test.test3.src ))  ...... ...... ..... } 

this function runs when have 3 different images when either of 3 equal each other in page. however, how make specify images equal each other, instead of doing of three.

for ex, if 1 image titled 'x' if 3 test1,test2,test of value 'x' run function , display message, however, displays same message other images (if equal 'y') id have separate messages somehow.

i'd separate comparison separate function current image element parameter , use method different image objects:

function compare(imgelem){   if((document.test.test1.src == document.test.test2.src && document.test.test2.src == document.test.test3.src ))     console.log(imgelem.id,"triggered");     // or else   } }  compare(document.test.test1); compare(document.test.test2); compare(document.test.test3); 

however solution might not accurate depending on how many elements you're comparing. large number of elements, try using map.


Comments

Popular posts from this blog

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -