-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhyCoding.js
More file actions
34 lines (24 loc) · 1 KB
/
whyCoding.js
File metadata and controls
34 lines (24 loc) · 1 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
// ******** WHY CODING? SECTION OF WEBSITE ********
// ******** Variables ********
//Initialise Google 'search box' and empty' (X) buttton in JS
const googleSearchText = document.getElementById('googleSearchTxt');
const emptyGoogleBtn = document.getElementById('emptyGoogleBtn');
// ******** Functions ********
//Function to make the 'empty' button (X) appear/disappear in Google Search text box (when text is entered/removed)
function toggleEmptyGoogleBtn() {
if(googleSearchText.value === "") {
emptyGoogleBtn.style.visibility = "hidden";
action.style.action = "";
}
else {
emptyGoogleBtn.style.visibility = "visible";
}
}
//Function to clear the Google Search Text when the 'empty' button (X) is clicked
function clearGoogle() {
emptyGoogleBtn.style.visibility = "hidden";
googleSearchText.value = "";
}
// ******** Event Listeners ********
googleSearchText.addEventListener("keyup", toggleEmptyGoogleBtn);
emptyGoogleBtn.addEventListener("click", clearGoogle);