-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path00-js-code-run-in-browser.html
More file actions
61 lines (39 loc) · 1.24 KB
/
00-js-code-run-in-browser.html
File metadata and controls
61 lines (39 loc) · 1.24 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
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
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>How to run javascript Code for Output</title>
</head>
<body>
<!-- 01 inline js -->
<!-- <script>
console.log("hello my name is javascript");
</script> -->
<!-- 02 External js-->
<!-- <script src="01-run-js.js"></script> -->
<script src="03-calculation.js"></script>
<!-- 03 Event Handler -->
<!-- <button onclick="myFunction()">Click Me</button>
<script>
function myFunction() {
console.log("hello my name is javascript");
}
</script> -->
<!-- 04 HTML Attribute -->
<!-- <a href="javascript:myFunction()">click me</a>
<script>
function myFunction() {
console.log("Hello my name is javascript");
}
</script> -->
<!-- 05 Data Attribute -->
<!-- <div data-custom="alert('hello form data Attribute!')">
click me
</div>
<script>
const element = document.querySelector('div');
element.addEventListener('click', function () { const code = element.getAttribute('data-custom'); if (code) { eval(code) } })
</script> -->
</body>
</html>