HTML通过按钮来显示、隐藏内容
【代码】HTML通过按钮来显示、隐藏内容。
·
<script type="text/javascript">
function openShutManager(oSourceObj,oTargeObj,shutAble,oOpenTip,oShutTip){
var sourceObj=typeof oSourceObj=="string"?document.getElementById(oSourceObj):oSourceObj;
var targeObj=typeof oTargeObj=="string"?document.getElementById(oTargeObj):oTargeObj;
var openTip=oOpenTip||"";
var shutTip=oShutTip||"";
if(targeObj.style.display!="none"){
if(shutAble) return;
targeObj.style.display="none";
if(openTip&&shutTip){
sourceObj.innerHTML=shutTip;
}
}else{
targeObj.style.display="block";
if(openTip&&shutTip){
sourceObj.innerHTML=openTip;
}
}
}
<h1><button onclick="openShutManager(this,'show1',false,'内容')">内容</button></h1>
<div id="show1">
<span>我是隐藏的内容</span>
</div>
更多推荐
已为社区贡献1条内容
所有评论(0)