-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-jquery.html
More file actions
53 lines (50 loc) · 1.65 KB
/
3-jquery.html
File metadata and controls
53 lines (50 loc) · 1.65 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery</title>
<style>
main {
margin-top: 100px;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<main>
<div>
<label for="number1">N1</label> <input id="number1" value="0" type="number"> +
<label for="number2">N1</label> <input id="number2" value="0" type="number">
<button id="calc">=</button>
<label for="total">Total</label> <input id="total" type="number">
</div>
</main>
</div>
<!-- without jQuery -->
<!--<script>-->
<!--console.log('native number1 = ' + document.getElementById('number1').value)-->
<!--document.getElementById('calc').addEventListener("click", event => {-->
<!--console.log('native calc btn clicked')-->
<!--document.getElementById('total').value = parseInt(document.getElementById('number1').value) + parseInt(document.getElementById('number2').value);-->
<!--});-->
<!--</script>-->
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<!-- with jQuery -->
<!--<script>-->
<!--$(document).ready(function () {-->
<!--console.log('jquery number1 = ' + $('.number1').val());-->
<!--$('#calc').click(event => {-->
<!--console.log('jquery calc btn clicked')-->
<!--});-->
<!--});-->
<!--</script>-->
<!-- jQuery document ready -->
<!--<script>-->
<!--$(document).ready(function () {-->
<!--console.log("ready!");-->
<!--});-->
<!--console.log("not ready!");-->
<!--</script>-->
</body>
</html>