I'm pretty new to all of this and still learning :s
我对这一切都很陌生,还在学习:s
So in my css, i've done this...
在我的css中,我做了这个。
.example {
display: none;
}
I have a button which when i click makes other divs invis as well as trying to make it so that .example will be visible.
我有一个按钮,当我点击它时它会创建其他divs的invis并尝试使它可见。example。
I am using an onClick function...this is where I set the other div invis...
我正在使用onClick函数…这是我设置另一个div invis的地方……
document.getElementById("thisdiv").style.display = "none";
I can't seem to figure out how to make the other div visible now?
我似乎想不出如何使其他div可见?
4 个解决方案
#1
0
document.getElementById("thisdiv").style.display = "block";
#2
0
Set the display to "block" or use jQuery's show() function
将显示设置为“块”或使用jQuery的show()函数
$('.example').show();
#3
0
Refer this:
参考:
$("#show").click(function(){
$(".example").css({"display":"block"});
});
$("#hide").click(function(){
$(".example").css({"display":"none"});
});
Fiddle:http://jsfiddle.net/981oek8z/
小提琴:http://jsfiddle.net/981oek8z/
#4
0
Since you haven't posted much of your source code I have created a little demo to show you how to set the display for all elements using a class.
由于您还没有发布很多源代码,因此我创建了一个小演示,向您展示如何使用类设置所有元素的显示。
This doesn't require jQuery
这并不需要jQuery
function showclass(){
document.getElementById('thisdiv').style.display="none";
var examples=document.getElementsByClassName('example');
for(var i=0; i<examples.length; i++){
examples[i].style.display="block";
}
}
.example{display:none;}
<button onclick="showclass()">Show example Class</button>
<div id="thisdiv"> This Div will disappear </div>
<div class="example">Example Div One</div>
<div class="example">Example Div Two</div>
<div class="example">Example Div Three</div>
I hope this helps, happy coding! :)
我希望这能有所帮助,快乐的编码!:)
#1
0
document.getElementById("thisdiv").style.display = "block";
#2
0
Set the display to "block" or use jQuery's show() function
将显示设置为“块”或使用jQuery的show()函数
$('.example').show();
#3
0
Refer this:
参考:
$("#show").click(function(){
$(".example").css({"display":"block"});
});
$("#hide").click(function(){
$(".example").css({"display":"none"});
});
Fiddle:http://jsfiddle.net/981oek8z/
小提琴:http://jsfiddle.net/981oek8z/
#4
0
Since you haven't posted much of your source code I have created a little demo to show you how to set the display for all elements using a class.
由于您还没有发布很多源代码,因此我创建了一个小演示,向您展示如何使用类设置所有元素的显示。
This doesn't require jQuery
这并不需要jQuery
function showclass(){
document.getElementById('thisdiv').style.display="none";
var examples=document.getElementsByClassName('example');
for(var i=0; i<examples.length; i++){
examples[i].style.display="block";
}
}
.example{display:none;}
<button onclick="showclass()">Show example Class</button>
<div id="thisdiv"> This Div will disappear </div>
<div class="example">Example Div One</div>
<div class="example">Example Div Two</div>
<div class="example">Example Div Three</div>
I hope this helps, happy coding! :)
我希望这能有所帮助,快乐的编码!:)