我编写了一个函数,用于在单击按钮时根据百分比生成结果,问题是我需要该函数重复 10 次,因此按钮的名称。迄今
roll10.onclick = function generate() {
var outcome = "";
var percent = r();
if (percent >= 0 && percent < 1) {
outcome = "Outcome 1";
} else if (percent >= 1 && percent < 10) {
outcome = "Outcome 2";
} else if (percent >= 10 && percent < 30) {
outcome = "Outcome 3";
} else {
outcome = "Outcome 4";
}
$("#results").append("<div class='result'>" + outcome);
}
幕布斯6054654
相关分类