-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample7.html
41 lines (32 loc) · 1018 Bytes
/
sample7.html
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
<h1 id ="heading">Name</h1>
<button onclick="diff(event)">John</button>
<button onclick="diff(event)" >Danny</button>
<button onclick="diff(event)">steve</button>
<script>
var Heading = document.getElementById("heading")
function diff(event){
Heading.textContent = event.target.textContent
}
</script>
<!-- METHOD 2 - NOT SUGGESTABLE -->
<!-- <h1 id ="heading">Name</h1>
<button id="john" onclick="names()">John</button>
<button id ="danny" onclick="name1()" >Danny</button>
<button id="steve" onclick="name2()">steve</button>
<script>
var Heading = document.getElementById("heading")
var J = document.getElementById("john")
var D = document.getElementById("danny")
var S = document.getElementById("steve")
function names(){
// J.textContent = "John"
Heading.textContent = J.textContent
}
function name1(){
Heading.textContent = D.textContent
}
function name2(){
Heading.textContent = S.textContent
}
</script>
-->