Skip to content

Commit 91918d4

Browse files
moving script elements inside the body
1 parent 8d212cd commit 91918d4

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

javascript/introduction-to-js-1/what-is-js/apply-javascript-external.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
</head>
66
<body>
77
<button>Click me</button>
8+
9+
<script src="script.js"></script>
810
</body>
9-
<script src="script.js"></script>
10-
</html>
11+
</html>

javascript/introduction-to-js-1/what-is-js/apply-javascript-internal.html

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
</head>
66
<body>
77
<button>Click me</button>
8-
</body>
9-
<script>
10-
function createParagraph() {
11-
var para = document.createElement('p');
12-
para.textContent = 'You clicked the button!';
13-
document.body.appendChild(para);
14-
}
158

16-
var buttons = document.querySelectorAll('button');
9+
<script>
10+
function createParagraph() {
11+
var para = document.createElement('p');
12+
para.textContent = 'You clicked the button!';
13+
document.body.appendChild(para);
14+
}
15+
16+
var buttons = document.querySelectorAll('button');
1717

18-
for(var i = 0; i < buttons.length ; i++) {
19-
buttons[i].addEventListener('click', createParagraph);
20-
}
21-
</script>
22-
</html>
18+
for(var i = 0; i < buttons.length ; i++) {
19+
buttons[i].addEventListener('click', createParagraph);
20+
}
21+
</script>
22+
</body>
23+
</html>

0 commit comments

Comments
 (0)