这里是代码,首先为什么div显示时,我把它的显示值设置为“无”;并有任何其他我需要修复,以使div出现在我点击按钮时? 感谢试图让按钮被点击时出现一个div
HTML
<button onclick="openTest()">Try it</button>
<div id="test">
</div>
CSS
#test {
width: 500px;
height: 500px;
background-color: lightblue;
}
JS
document.getElementById("test").style.display ="none";
function openTest() {
document.getElementById("test").style.display = "block";
}
这里是一个小提琴https://jsfiddle.net/SnubbenGuden/6092dquv/4/ –
你的功能没有被调用。在javascript中将diviner添加到div中。 –
对于您在本网站上提出的所有问题,请点击此处查看:http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – baao