gpt4 book ai didi

javascript - 单击以显示更多 - 也许是 JS?

转载 作者:行者123 更新时间:2023-12-04 01:48:18 25 4
gpt4 key购买 nike

我不确定使用什么语言或如何执行此操作,但我希望在页面上有一个词,点击后,它会在下面显示更多内容。再点一下,那玩意又会躲起来?有什么想法吗?

最佳答案

基本上,您需要操作要隐藏/显示的元素的 display CSS 属性:

<span id="showHide">Show</span>
<div id="foo" style="display:none">Here is some text</div>

<script>
document.getElementById("showHide").onclick = function() {
var theDiv = document.getElementById("foo");
if(theDiv.style.display == 'none') {
theDiv.style.display = 'block';
this.innerHTML = 'Hide';
} else {
theDiv.style.display = 'none';
this.innerHTML = 'Show';
}
}
</script>

关于javascript - 单击以显示更多 - 也许是 JS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2757999/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com