用JavaScript改变DIV可见性
changing DIV visibility with JavaScript
编辑:由于这个问题已经变得相当流行,我将修复这个问题,所以它将是一个工作代码示例。原来的问题仍然列出,但是代码可以工作。
我试图在按下按钮后显示一个div,但这不起作用,你知道为什么吗?
<form action="insert.php" method="POST" align="right" id="post_form">
<input type="button" value="click me" onClick="show()">
<div id="show_button"> fdsfds </div><br>
</form>
#show_button{
visibility:hidden;
}
function show(){
// alert("cheked the button - worked");
document.getElementById("show_button").style.visibility= 'visible' ;
}
把你的CSS改成:
#show_button{
display: none
}
和你的javascript:
function show(){
//alert("cheked the button - worked");
document.getElementById('show_button').style.display= 'block' ;
}
输入错误将document.getElementById(show_button)
改为document.getElementById("show_button")
function show(){
document.getElementById("show_button").style.visibility= "visible" ;
}
试试这个:
function show(){
//alert("cheked the button - worked");
document.getElementById("show_button").style.visibility= "visible" ;
}
或
function show(){
//alert("cheked the button - worked");
document.getElementById(show_button).style.display= "inline" ;
}
document.getElementById(show_button)
-:语法错误,缺少引号" " !
相关文章:
- D3在一个调用中绘制不同的SVG形状,没有可见性
- jQuery css可见性在load方法中不起作用
- 页面可见性API实际上支持操作系统屏幕锁定吗
- 有没有一种方法可以从隐藏的可见性(CSS,JS)中获得淡入效果
- JavaScript可见性不起作用('隐藏'起作用,'可见'不起作用)
- 从内部回调的可见性
- Openlayers 3为了可见性而绑定到Vector层的复选框没有任何作用
- 在另一个下拉列表中的选择上切换下拉列表中选项的可见性
- 需要切换2个DIV的DIV可见性
- 如何切换DIV元素的可见性
- 滚动上的交替 DIV 可见性
- 如何根据另一个 DIV 内容的可见性显示 DIV 内容
- 无法手动将 DIV 元素上的可见性设置为 true.“TH:IF”问题
- 使用 jquery 根据链接单击切换 DIV 可见性
- 根据选择框更改 DIV 可见性
- 在gridview事件处理程序中切换DIV可见性的代码不工作
- 当次要Div '的可见性被设置为'none'时,如何改变Div对齐方式
- 用JavaScript改变DIV可见性
- javascript中的Div可见性
- 切换DIV's的可见性点击