我有以下代码。正如您所看到的,按钮隐藏了对单词的解释。问题是我无法弄清楚如何在隐藏解释的情况下启动页面。我无法绕过这个。
<script type="text/javascript">
function showHide(divId){
var theDiv = document.getElementById(divId);
if(theDiv.style.display=="none"){
theDiv.style.display="";
}else{
theDiv.style.display="none";
}
}
</script>
<p><b>AMBIVALENT</b>
<input type="button" onclick="showHide('-1')" value="Hide/Show">
<div id = "-1" style="">indecisive, having mixed feelings</div></p>
答案 0 :(得分:3)
显示:无风格
<div id = "-1" style="display:none;">indecisive, having mixed feelings</div>
答案 1 :(得分:0)
直接将样式添加到div以开始。
<div id = "-1" style="display:none;">indecisive, having mixed feelings</div>
答案 2 :(得分:0)
鉴于你的代码:
<p><b>AMBIVALENT</b>
<input type="button" onclick="showHide('-1')" value="Hide/Show">
<div id = "-1" style="">indecisive, having mixed feelings</div></p>
只需添加&#34;显示&#34;物业价值为&#34;无&#34;到持有描述的元素。像这样:
<div id = "-1" style="display: none">indecisive, having mixed feelings</div></p>
希望这有帮助!
答案 3 :(得分:0)
如果我理解正确,你应该使用它:
<div id = "-1" style="display: none">indecisive, having mixed feelings</div></p>
此致