-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjQueryQuizI.txt
49 lines (37 loc) · 1.09 KB
/
jQueryQuizI.txt
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
1. In jQuery terminology, what is the difference between the “jQuery function” and the “jQuery object”?
Answer:
The jQuery function is the value of jQuery or of $. This is the function that creates
jQuery objects and registers handlers to be invoked when the DOM is ready;
it also serves as the jQuery namespace.
A jQuery object is an object returned by the jQuery function. A jQuery object represents a set of
document elements and can also be called a “jQuery result”, a “jQuery set”, or a “wrapped set”.
2. Write jQuery code to find all h1 elements that are children of a div element and make their background
color red.
Sample HTML:
<body>
<h1>abc</h1><br><div>
<h1>div-1</h1>
<h1>div-2</h1>
</div>
<h1>xyz</h1>
</body>
Answer:
$(function () {
$("div h1").css("color", "red");
});
3. Use a jQuery method to insert the text "YES!" at the end of the <p> element.
<!DOCTYPE html>
<html>
<head>
<script>
<!—INSERT YOUR JQUERY CODE HERE - - >
</script>
</head>
<body>
<p>Is jQuery FUN or what? </p>
</body>
</html>
Answer:
$(function () {
$("p").append('YES!');
});