-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjQuery.html
More file actions
50 lines (47 loc) · 1.71 KB
/
jQuery.html
File metadata and controls
50 lines (47 loc) · 1.71 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<title>jQuery Demo</title>
</head>
<body></body>
<script>
$(document).ready(function () {
$("html").append(
"<body>\
<div id='container'>\
<div id='inner'>\
<h1>Basic jQuery</h1>\
<p id='1'>Click for Step 340.1</p>\
<p id='2'>Paragraph 2</p>\
<p id='3'>Click for Step 340.2</p>\
</div>\
</div>\
</body>",
); /*
$("#2").css({ color: "red" });
$("#3").click(function () {
$("h1").hide();
});*/
$(document).ready(function () {
// HAD to add the "$(document).ready()" part for this to work; "function()" desnn't run as a standalone ()
$("#1").click(function () {
// "When the element with id==1 is clicked, do what's in the curly brackets"
$("#2").append(
// "Append the text below to the element with id==2, once the above happens"
" - This was APPENDED here <em>after</em> you clicked the sentence above!<hr>(Click below to hide these lines...)",
);
});
});
$("document").ready(function () {
// What I learned from the above comment made creating this () much easier...
$("#3").click(function () {
$("#2").hide("slow"); // Same as above (); when element with id==3 is clicked, SLOWLY hide the element with id==2
});
});
});
</script>
</html>