Huguet57 | ae6d974 | 2018-07-23 01:07:26 +0200 | [diff] [blame] | 1 | // Get the box
|
| 2 | var searchBox = document.getElementById('searchBox');
|
| 3 |
|
| 4 | // Get the button that opens the box
|
| 5 | var searchButton = document.getElementById("searchButton");
|
| 6 |
|
| 7 | // Get the <span> element that closes the box
|
| 8 | var closeBox = document.getElementsByClassName("closeBox")[0];
|
| 9 |
|
| 10 | // When the user clicks the button, open the box
|
| 11 | searchButton.onclick = function() {
|
| 12 | searchBox.style.display = "block";
|
| 13 | }
|
| 14 |
|
| 15 | // When the user clicks on <span> (x), close the box
|
| 16 | closeBox.onclick = function() {
|
| 17 | searchBox.style.display = "none";
|
| 18 | }
|
| 19 |
|
| 20 | // When the user clicks anywhere outside of the box, close it
|
| 21 | window.onclick = function(event) {
|
| 22 | if (event.target == searchBox) {
|
| 23 | searchBox.style.display = "none";
|
| 24 | }
|
| 25 | } |