Aug
12
用javascript控制DIV层等html元素的显示和隐藏
雪糕先生 2009/08/12
12:56
12:56
1。编写js函数
2. 要显示/隐藏的html元素加上 id 属性
3,添加按钮,链接等触发 js 函数
javascript显示隐藏层
你先给div 取个ID=“AA”thisdiv=AA
javascript隐藏/显示表单对象
javascript隐藏/显示表单对象
el是对象的id,不管是tr或者table等等先设置一下id,然后进行调用。
例:
<a onclick="expandIt('ttchild'); return false" href="#" >try it</a>
<tr id="ttchild"><td width="18">Example</td></tr>
javascript控制页面控件隐藏显示的两种方法
javascript控制页面控件隐藏显示的两种方法,方法的不同之处在于控件隐藏后是否还在页面上占位
方法一:
方法二:
方法一隐藏后 页面的位置还被控件占用 只是不显示 类似于.net验证控件的Display=Static
方法二隐藏后 页面的位置不被占用 类似于.net验证控件的Display=Dynamic
引用
<script type="text/javascript">
function display(id){
var traget=document.getElementById(id);
if(traget.style.display=="none"){
traget.style.display="";
}else{
traget.style.display="none";
}
}
</script>
function display(id){
var traget=document.getElementById(id);
if(traget.style.display=="none"){
traget.style.display="";
}else{
traget.style.display="none";
}
}
</script>
2. 要显示/隐藏的html元素加上 id 属性
引用
<table>
<tr id="menu" >
<td>控制这个tr的显示/隐藏</td>
</tr>
</table>
<tr id="menu" >
<td>控制这个tr的显示/隐藏</td>
</tr>
</table>
3,添加按钮,链接等触发 js 函数
引用
<input type="button" onclick="display('menu')" value="显示/隐藏"/>
<a href="#" onclick="display('menu')" >显示/隐藏</a>
<a href="#" onclick="display('menu')" >显示/隐藏</a>
javascript显示隐藏层
引用
<div id="" style="display:none;">广告</div>
<input type="botton" onclick="函数">
<script language=javascript>
function 函数{
if(thisdiv.style.display=='none'){
thisdiv.style.display=""
}
else
thisdiv.style.display="none"
}
</script>
<input type="botton" onclick="函数">
<script language=javascript>
function 函数{
if(thisdiv.style.display=='none'){
thisdiv.style.display=""
}
else
thisdiv.style.display="none"
}
</script>
你先给div 取个ID=“AA”thisdiv=AA
javascript隐藏/显示表单对象
javascript隐藏/显示表单对象
引用
<SCRIPT language=javascript>
function expandIt(el) {
whichEl =document.getElementById(el)
if (whichEl.style.display == 'none') {
whichEl.style.display = '';
}
else {
whichEl.style.display = 'none';
}
}
</SCRIPT>
function expandIt(el) {
whichEl =document.getElementById(el)
if (whichEl.style.display == 'none') {
whichEl.style.display = '';
}
else {
whichEl.style.display = 'none';
}
}
</SCRIPT>
el是对象的id,不管是tr或者table等等先设置一下id,然后进行调用。
例:
<a onclick="expandIt('ttchild'); return false" href="#" >try it</a>
<tr id="ttchild"><td width="18">Example</td></tr>
javascript控制页面控件隐藏显示的两种方法
javascript控制页面控件隐藏显示的两种方法,方法的不同之处在于控件隐藏后是否还在页面上占位
方法一:
引用
document.all<"PanelSMS">.style.visibility="hidden";
document.all<"PanelSMS">.style.visibility="visible";
document.all<"PanelSMS">.style.visibility="visible";
方法二:
引用
document.all<"PanelSMS">.style.display="none";
document.all<"PanelSMS">.style.display="inline";
document.all<"PanelSMS">.style.display="inline";
方法一隐藏后 页面的位置还被控件占用 只是不显示 类似于.net验证控件的Display=Static
方法二隐藏后 页面的位置不被占用 类似于.net验证控件的Display=Dynamic
赞助商链接
分类
热门文章
- [21863]五种方法安装Windows...
- [5891]雪糕乐园小游戏集2.04版!...
- [5750]开机自动检测网络状态运行程序...
- [5424]双路由器上网的连接和设置方法
- [4733]Google提供的免费天气预...
- [4693]QQ临时会话(强制聊天)工具...
- [4623]EvaPhone - 无需注...
- [4608]ESET NOD32最新升级...
- [4487]WINDOWS 7 如何快速...
- [4039][原创]雪糕乐园-图片轮换屏...
右下角,可关闭,检测IP,根据来访地区在框架中打开不同的网页
Godaddy免费空间去掉广告方法
