-
Notifications
You must be signed in to change notification settings - Fork 0
/
myScript.js
59 lines (55 loc) · 1.78 KB
/
myScript.js
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
51
52
53
54
55
56
57
58
59
/* Function returns day of the week by calling Date().getDay(), then finding
the case which matches and assigning date to that value.
*/
function getDate() {
var date;
switch (new Date().getDay()) {
case 0:
date = "Sunday";
break;
case 1:
date = "Monday";
break;
case 2:
date = "Tuesday";
break;
case 3:
date = "Wednesday";
break;
case 4:
date = "Thursday";
break;
case 5:
date = "Friday";
break;
case 6:
date = "Saturday";
break;
}
window.alert("Today is: " + date);
}
/* Function to switch between classes of a specific element by removing the current
class and adding the other.
*/
function changeFont() {
if (document.getElementById("chText").classList.contains('firstfont')){
document.getElementById("chText").classList.remove('firstfont');
document.getElementById("chText").classList.add('secondfont');
}
else if (document.getElementById("chText").classList.contains('secondfont')){
document.getElementById("chText").classList.remove('secondfont');
document.getElementById("chText").classList.add('firstfont');
}
}
/* Function to display a user's name and interest after being typed into input boxes. If
either one is left blank, an alert will appear on the screen.
*/
function takeInput(){
var name = document.getElementById("name").value;
var interest = document.getElementById("interest").value;
if(name == "" || interest == ""){
window.alert("WARNING!!! \n You must enter some text")
}else{
window.alert("Hello " + name + "\n I see you are interested in " + interest);
}
}