forked from jhu-ep-coursera/fullstack-course4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (29 loc) · 816 Bytes
/
Copy pathscript.js
File metadata and controls
41 lines (29 loc) · 816 Bytes
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
// Event handling
document.addEventListener("DOMContentLoaded",
function (event) {
function sayHello (event) {
this.textContent = "Said it!";
var name =
document.getElementById("name").value;
var message = "<h2>Hello " + name + "!</h2>";
document
.getElementById("content")
.innerHTML = message;
if (name === "student") {
var title =
document
.querySelector("#title")
.textContent;
title += " & Lovin' it!";
document
.querySelector("h1")
.textContent = title;
}
}
// Unobtrusive event binding
document.querySelector("button")
.addEventListener("click", sayHello);
}
);
// document.querySelector("button")
// .onclick = sayHello;