function loadImage(a, b, c, d) {
if (a == yes )
{
document.getElementById(d).style.display = 'inline';
}
else if (b == yes)
{
document.getElementById(d).style.display = 'inline';
}
else if (c == yes)
{
document.getElementById(d).style.display = 'inline';
}
else
{
document.getElementById(d).style.display = 'none';
}
}
I need to use this function 10 times in my code, everytime with different a, b, c and different id. I don't know how to write variable id. Can someone help me?
loadImage(Blood, Unholy, FrostDK, dkclass);
loadImage(Balance, Feral, Guardian, druidclass);
You can put all the parameters in an array.
var params = [
{ a: Blood, b: Unholy, c: FrostDK, d: dkclass },
{ a: Balance, b: Feral, c: Guardian, d: druidclass },
...
];
params.forEach(function(x) {
loadImage(x.a, x.b, x.c, x.d);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.