我想设置一个功能,比如点击一个链接可以显示一个p。当点击另一个链接时,之前的显示的p自动隐藏,新的p显示出来。我应该如何实现?
我的代码如下:
HTML
Text 1
Text 2
Text 3
This will show up when the Text 1 link is pressed.
This will show up when the Text 2 link is pressed.
This will show up when the Text 3 link is pressed.
Javascript
function unhide(pID) {
var item = document.getElementById(pID);
if (item) {
item.className='unhidden';
}
}
CSS
.hidden { display: none; }
.unhidden { display: block; }
原问题: Show one p and hide the previous showing p
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
认证高级PHP讲师