我想要的是,生成一个显示在ah标签中的随机值,并在另一个标签中显示相对于该随机值的好值。
var first = ['1+2', '10+20', '100+200'];
var second = ['3', '30', '300'];
var first_value = first[Math.floor(Math.random()*first.length)];
var second_value = second[Math.floor(Math.random()*second.length)];
document.getElementById('first_value').innerHTML = first_value;
document.getElementById('second_value').innerHTML = second_value;
Run Code Online (Sandbox Code Playgroud)
目前,所有内容都是随机生成的,生成的2个值之间没有关系。
如果随机选择“ 10 + 20”,我想在第二个html标签中显示“ 30”。