我将要完成我的新学校项目,我想知道,如何通过按钮更改文本的可见性?就像当我单击按钮时一样,文本将是可见的,而当我再次单击它时,它将是不可见的;或者当我单击另一个按钮时,将是不可见的。使用JavaScript或CSS。
Stack Overflow不同于“ gib mi solushons”类型的网站。尝试编写一些代码并在此处共享。这是学习资源:https://www.w3schools.com/查看JS onclick
事件。CSSdisplay
和HTML标签的语法结构。它可能会帮助您。然后,当您需要显示一些代码时,请尝试再次发布,我们将很乐意为您提供帮助。
<html>
<body>
<p id="hiddenText">this text is visible now</p>
<button onclick="show()">Show</button>
<button onclick="hide()">hide</button>
</body>
<script>
function show(){
document.getElementById("hiddenText").style.visibility = "visible";
}
function hide(){
document.getElementById("hiddenText").style.visibility = "hidden";
}
</script>