Javascript error [object HTMLParagraphElement]
Javascript error [object HTMLParagraphElement]
我是Javascript中的beginer,需要一些帮助。所以,我需要,当我按下按钮时,段落"左侧"出现
<div id="content">
<script>
function myFunction() {
document.getElementById("contentp").innerHTML = leftside;
var x = document.getElementById("leftside")
x.style.display = "normal";
}
</script>
<button id="buttonI" type="button" onclick="myFunction()">Show left side!</button>
<p id="leftside" style="display: none">Left side</p>
<p id="contentp"></p>
x.style.display = "block";
将其设置为block
或除none
之外的display
的其他值
您必须将左侧附加到contentp
,并将其显示属性设置为block
。normal
不是有效的选项
<script>
function myFunction() {
document.getElementById("contentp").appendChild(document.getElementById("leftside"));
document.getElementById("leftside").style.display = "block";
}
</script>
<button id="buttonI" type="button" onclick="myFunction()">Show left side!</button>
<p id="leftside" style="display: none">Left side</p>
<p id="contentp"></p>
相关文章:
- 没有找到相关文章