可以更改显示: block ;没有人;使用 JavaScript。我想每次打开页面时显示其中两个。但我希望它是随机的,并且每次打开页面时都会改变。
有人可以帮我解决这个问题吗?
最佳答案
下面的每次都会随机隐藏其中两个。您可以重复使用它来只显示两个。
window.onload = function() {
var ran = Math.round(Math.random() * 6);
document.getElementById("" + ran).style.display = 'none';
ran = Math.round(Math.random() * 6);
document.getElementById("" + ran).style.display = 'none';
};
P.S:从我的头顶开始。未测试。 P.S:需要检查两次随机调用是否给出相同的数字
关于javascript - 是否可以在每次打开页面时更改div的显示属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8273780/