-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy path01-04-20202Notes.txt
More file actions
227 lines (206 loc) · 5.95 KB
/
01-04-20202Notes.txt
File metadata and controls
227 lines (206 loc) · 5.95 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
JQuery Selectors
===============
- To Select and manipulate HTML DOM elements.
- Selector can access any HTML element and can dynamically control the element.
- Different types of JQuery Selectors
Selector Syntax Description
===========================================
* $("*") It is used to select all elements
#id $("#id") It is used to select any element
based on its ID.
.class $(".class") It is used to select any element
by using its class name.
element $("tag") It is used to select any element
by using its tag name.
multiple $("h2,div,p") It will select the specified.
Ex:
<!DOCTYPE html>
<html>
<head>
<title>JQuery Demo</title>
<style>
div {
width: 400px;
height: 50px;
margin: auto;
margin-top: 20px;
box-shadow: 0px 3px 4px darkcyan;
border:2px solid darkcyan;
text-align: center;
font-size: 2em;
}
p {
text-align: center;
background-color: yellow;
}
h2 {
text-align: center;
color: red;
}
</style>
<script src="../node_modules/jquery/dist/jquery.js">
</script>
<script>
$(function(){
$("div").text("Accessed by using Tag Name");
$("#para").text("Accessed by Id");
$(".heading").text("Accessed by class name");
})
</script>
</head>
<body>
<div></div>
<p id="para"></p>
<h2 class="heading"></h2>
</body>
</html>
Selector Syntax Description
===========================================
:first #("li:first") It will access the first li element.
:last #("li:last") It will access the last li element.
:even #("tr:even") It will access even occurance.
:odd #("tr:odd") It will access odd occurance.
Ex:
<!DOCTYPE html>
<html>
<head>
<title>JQuery Demo</title>
<style>
div {
width: 400px;
height: 50px;
margin: auto;
margin-top: 20px;
box-shadow: 0px 3px 4px darkcyan;
border:2px solid darkcyan;
text-align: center;
font-size: 2em;
}
p {
text-align: center;
background-color: yellow;
}
h2 {
text-align: center;
color: red;
}
</style>
<script src="../node_modules/jquery/dist/jquery.js">
</script>
<script>
$(function(){
$("div").text("Accessed by using Tag Name");
$("#para").text("Accessed by Id");
$(".heading").text("Accessed by class name");
$("li:first").css("color","red");
$("li:last").css("color","red");
$("li:odd").css("background-color","yellow");
$("li:even").css("background-color","green");
})
</script>
</head>
<body>
<ol>
<li>Item-1</li>
<li>Item-2</li>
<li>Item-3</li>
<li>Item-4</li>
<li>Item-5</li>
</ol>
<div></div>
<p id="para"></p>
<h2 class="heading"></h2>
</body>
</html>
JQuery HTML and CSS
- JQuery provides a set of functions with are used to manipulate HTML and CSS.
1. html() : It is similar to innerHTML of javascript.
It allows text with formats.
2. text() : It is similar to innerText of JS. It is plain
text without formats.
Ex:
<head>
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script>
$(function(){
$("#p1").html(`<b><i>Text with Format</b></i>`);
$("#p2").text(`<b><i>Text without format</b></i>`);
})
</script>
</head>
<body>
<p id="p1"></p>
<p id="p2"></p>
</body>
3. val() : It is used to set or get a value present in
element. like textbox, checkbox, radio, select
Ex:
<head>
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script>
$(function(){
$("#txtName").val("John");
})
</script>
</head>
<body>
<dl>
<dt>User Name</dt>
<dd><input type="text" id="txtName"></dd>
</dl>
</body>
4. css() : It is used to apply css styles for any HTML
element.
Single Style
$("div").css("property", "value");
Multiple Styles
$("div").css({"property":"value", "property":"value"..});
Ex:
<head>
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script>
$(function(){
$("div").html(`Welcome to JQuery CSS`);
$("div").css({"background-color":"yellow","color":"red","text-align":"center"});
})
</script>
</head>
<body>
<div>
</div>
</body>
5. before() ] It is used to add content before and
6. after() ] after the current element.
Ex:
<head>
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script>
$(function(){
$("#p1").before(`<p>New Para before current paragraph</p>`);
$("#p1").after(`<h2>Heading after Paragraph</h2>`);
})
</script>
</head>
<body>
<p id="p1">Current Paragraph</p>
</body>
7. prepend() : It adds new content as prefix with out
deleting exisiting.
8. append() : It adds new content as suffix without
deleting exisiting.
Ex:
<head>
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script>
$(function(){
$("#p1").before(`<p>New Para before current paragraph</p>`);
$("#p1").after(`<h2>Heading after Paragraph</h2>`);
$("#p2").prepend("Welcome to ");
$("#p2").append("-I Technologies");
})
</script>
</head>
<body>
<p id="p1">Current Paragraph</p>
<p id="p2">Naresh</p>
</body>