-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgizlibuton.html
More file actions
50 lines (49 loc) · 1.8 KB
/
gizlibuton.html
File metadata and controls
50 lines (49 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Show and hide div with JavaScript</title>
<script>
var button_beg = '<button style="border: none;background-color: transparent;outline: none;width: 16px;height: 16px" id="button" onclick="showhide()">', button_end = '</button>';
var show_button = '', hide_button = '';
function showhide() {
var div = document.getElementById( "hide_show" );
var showhide = document.getElementById( "showhide" );
if ( div.style.display !== "none" ) {
div.style.display = "none";
button = show_button;
showhide.innerHTML = button_beg + button + button_end;
} else {
div.style.display = "block";
button = hide_button;
showhide.innerHTML = button_beg + button + button_end;
}
}
function setup_button( status ) {
if ( status == 'show' ) {
button = hide_button;
} else {
button = show_button;
}
var showhide = document.getElementById( "showhide" );
showhide.innerHTML = button_beg + button + button_end;
}
window.onload = function () {
setup_button( 'hide' );
showhide(); // if setup_button is set to 'show' comment this line
}
</script>
</head>
<body>
<center>
<div id="showhide"></div>
<div id="hide_show">
<p>This div will be show and hide on button click</p><br><p>transparent</p><br>
<textarea autofocus></textarea><br>
</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
kaynak:<br>
https://stackoverflow.com/a/22672469<br>
https://stackoverflow.com/questions/16308779/how-can-i-hide-show-a-div-when-a-button-is-clicked<br>
</center>
</body>
</html>