gpt4 book ai didi

JavaScript 隐藏/显示元素

转载 作者:IT老高 更新时间:2023-10-28 13:12:06 25 4
gpt4 key购买 nike

按下后如何隐藏“编辑”链接?当我按下编辑时,我还可以隐藏“lorem ipsum”文本吗?

<script type="text/javascript">
function showStuff(id) {
document.getElementById(id).style.display = 'block';
}
</script>


<td class="post">

<a href="#" onclick="showStuff('answer1'); return false;">Edit</a>
<span id="answer1" style="display: none;">
<textarea rows="10" cols="115"></textarea>
</span>

Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum
</td>

最佳答案

function showStuff(id, text, btn) {
document.getElementById(id).style.display = 'block';
// hide the lorem ipsum text
document.getElementById(text).style.display = 'none';
// hide the link
btn.style.display = 'none';
}
<td class="post">

<a href="#" onclick="showStuff('answer1', 'text1', this); return false;">Edit</a>
<span id="answer1" style="display: none;">
<textarea rows="10" cols="115"></textarea>
</span>

<span id="text1">Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</span>
</td>

关于JavaScript 隐藏/显示元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6242976/

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