I am new to Javascript so I apologize if I am using the wrong terms. I have a code where I need to show some HTML images, stored as variables containing multiple items in specific positions (defined by the class) such as:
var fruit: ["<img class='item1' src='" + Banana + "'>" +
"<img class='item2' src='" + Apple + "'>" +
"<img class='item3' src='" + Grapes + "'>" +
"<img class='item4' src='" + Banana + "'>" +
"<img class='item5' src='" + Grapes + "'>" +
"<img class='item6' src='" + Pear + "'>"],
Later, I need to use all of these items in a bigger picture called stimulus, e.g.:
stimulus: "<div class='container'> <img class='background' src='" + Background + "'>" + fruit + "</div>",
But then I need to only show 3 random fruits among the 6 listed in fruit. Is there any way I can do this, even if my images are not technically items of an array? Note: In other variables, let's say fruit_2, I will want to use different combinations of fruit and change their position (so assign them to different classes, with one item per class), and do the same thing that I am trying to do with the fruit variable here. This is why I am not storing images as strings in an array. Thank you for your time!
Aucun commentaire:
Enregistrer un commentaire