Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
49
rated 0 times [  52] [ 3]  / answers: 1 / hits: 156116  / 12 Years ago, mon, july 9, 2012, 12:00:00

Hello I have the following 2 JavaScript functions to open up a div and to close it.



<script>
function show() {
if(document.getElementById('benefits').style.display=='none') {
document.getElementById('benefits').style.display='block';
}
}
</script>



<script>
function close() {
if(document.getElementById('benefits').style.display=='block') {
document.getElementById('benefits').style.display='none';
}
}
</script>


Here is the html:



<div id=opener><a href=#1 name=1 onclick=show()>click here</a></div>
<div id=benefits style=display:none;>
some input in here plus the close button
<div id=upbutton><a onclick=close()></a></div>
</div>


For some reason the show function works how it should, but the close button does not do its job. So if there is someone who could help me out I really would appreciate. Thanks a lot.


More From » function

 Answers
3
<script> 
function show() {
if(document.getElementById('benefits').style.display=='none') {
document.getElementById('benefits').style.display='block';
}
return false;
}
function hide() {
if(document.getElementById('benefits').style.display=='block') {
document.getElementById('benefits').style.display='none';
}
return false;
}
</script>


<div id=opener><a href=#1 name=1 onclick=return show();>click here</a></div>
<div id=benefits style=display:none;>some input in here plus the close button
<div id=upbutton><a onclick=return hide();>click here</a></div>
</div>

[#84382] Saturday, July 7, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jalyn

Total Points: 173
Total Questions: 96
Total Answers: 90

Location: Somalia
Member since Mon, Feb 27, 2023
1 Year ago
jalyn questions
;