-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery_sample.htm
220 lines (169 loc) · 10.2 KB
/
jquery_sample.htm
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script type="text/javascript" src="lib/jquery/jquery-1.3.2.js"></script>
<script type="text/javascript" src="jquery_sample.js"></script>
<style type="text/css">
<!--
/* ----- Uncomment the global selector below to over-ride the default margin and padding added to all tags ----- */
*{padding: 0; margin: 0;}
/* ----- global default/initial styles ----- */
body {background-color:#fff; margin: 20px; padding: 0;height:100%}
/* ----- base default font size, type, and line height ----- */
html body{font: 62.5%/1.4em Arial, Helvetica, sans-serif;color:#333333;}
html>body{font: 62.5%/1.4em Arial, Helvetica, sans-serif;color:#333333;}
html {height:100%}
/* ----- add selectors here for font sizing ----- */
.alert{font-size: 1.1em}
p, table, ul, dl {font-size: 1.2em}
code {font-size: 1.4em}
h2 {font-size: 1.6em}
/* ----- base links ----- */
a:link {color: #CC6633;}
a:visited {color: #CC6633;}
a:hover {color: #999966;}
a:active {color: #CC6633;}
a:focus{color: #CC6633;}
h2{padding-top:20px;}
p {line-height:1.4em;margin-right:10px;}
div.contentToChange p {margin:10px 30px 10px 30px;}
ul li {display:inline}
hr{margin:10px 0;}
pre {
border: 1px solid black;
border-color: #BBB #DDD #DDD #BBB;
margin:5px 10px 0 0;
padding: 1em;
line-height: 1.5;
background: white;
overflow: auto;
display:none;
}
code{color:#000000}
.javascript .comment {
color:#999999;
}
.javascript .string{
color:blue;
}
.javascript .keywords {
color:blue;
font-weight:bold;
}
.javascript .global {
color : #0000FF;
}
.javascript .brackets {
color:#FF0000;
}
.changeP{
color: #FFFFFF;
border: 2px solid #CC6633;
position: absolute;
z-index: 1;
width: 150px;
left: 0px;
top: 0px;
background-color: #CC6633;
padding:10px;
line-height:1.4em;
}
.alert {
font-weight: bold;
color: #FFFFFF;
background-color: #FF0000;
padding: 10px;
text-transform:uppercase;
}
.addedtext{
color:#FF0000;
}
-->
</style>
<title>JQuery</title>
</head>
<body>
<p><a href="http://codylindley.com/Javascript/241/jquery-to-the-rescue">JQuery Demo From 'Cody's jQuery Examples'</a></p>
<div style="float:left;width:40%;height:100%">
<h2>Column 1:</h2>
<hr size="1" noshade="noshade" color="#e8e8e8" />
<p><strong>Example A</strong> (View in External Browser)</p>
<p>Get number of paragraphs in column 2 and display that number in an alert box. Including the one in the red box.</p>
<input type="button" value="# of Paragraphs" class="buttonAsize" />
<a href="#" class="codeButtonA">Show / Hide jquery code</a>
<pre class="codeA"><code class="javascript">//Code for example A
$("input.buttonAsize").click(function(){ alert($("div.contentToChange").find("p").size()); });
//show code example A
$("a.codeButtonA").click(function(){$("pre.codeA").toggle()});
</code></pre>
<hr size="1" noshade="noshade" color="#e8e8e8" />
<p><strong>Example B</strong></p>
<p>Animate a paragraph in Column 2 by using a slide animation.</p>
<input type="button" value="Slide Out" class="buttonBslideup" />
<input type="button" value="Slide In" class="buttonBslidedown" />
<a href="#" class="codeButtonB">Show / Hide jquery code</a>
<pre class="codeB"><code class="javascript">//Code for example B
$("input.buttonBslidedown").click(function(){ $("div.contentToChange").find("p.fourthparagraph:hidden").slideDown("slow"); });
$("input.buttonBslideup").click(function(){ $("div.contentToChange").find("p.fourthparagraph:visible").slideUp("slow"); });
//show code example B
$("a.codeButtonB").click(function(){$("pre.codeB").toggle()});
</code></pre>
<hr size="1" noshade="noshade" color="#e8e8e8" />
<p><strong>Example C</strong></p>
<p>Add/Remove text from the end of all <p> elements in column 2 except the paragraph in the red box.</p>
<input type="button" value="Add" class="buttonCAdd" />
<input type="button" value="Remove" class="buttonCRemove" />
<a href="#" class="codeButtonC">Show / Hide jquery code</a>
<pre class="codeC"><code class="javascript">//Code for example C
$("input.buttonCAdd").click(function(){$("div.contentToChange").find("p").not(".alert").append("<strong class=\"addedtext\"> This text was just appended to this paragraph</strong>")});
$("input.buttonCRemove").click(function(){$("strong.addedtext").remove()});
//show code example C
$("a.codeButtonC").click(function(){$("pre.codeC").toggle()});
</code></pre>
<hr size="1" noshade="noshade" color="#e8e8e8" />
<p><strong>Example D</strong></p>
<p>Remove paragraph with fade and animation.</p>
<input type="button" value="Remove" class="buttonDhide" />
<a href="#" class="codeButtonD">Show / Hide jquery code</a>
<pre class="codeD"><code class="javascript">//Code for example D
$("input.buttonDhide").click(function(){ $("div.contentToChange").find("strong").hide("slow"); });
//show code example D
$("a.codeButtonD").click(function(){$("pre.codeD").toggle()});
</code></pre>
<hr size="1" noshade="noshade" color="#e8e8e8" />
<p><strong>Example E</strong></p>
<p>Change the font weight and color of all Italic text in column 2 by adding CSS properties and values to all <em> elements.</p>
<input type="button" value="Change Italics" class="buttonEitalics" />
<a href="#" class="codeButtonE">Show / Hide jquery code</a>
<pre class="codeE"><code class="javascript">//Code for example E
$("input.buttonEitalics").click(function(){ $("div.contentToChange").find("em").css({color:"#993300", fontWeight:"bold"}); });
//show code example E
$("a.codeButtonF").click(function(){$("pre.codeF").toggle()});
</code></pre>
<hr size="1" noshade="noshade" color="#e8e8e8" />
<p><strong>Example F</strong></p>
<p>Change the CSS on the first paragraph in Column 2 by adding a class value to the <p> element. Adding this new class value to the first p element will place the paragraph in a absolute position box in the upper left hand corner.</p>
<input type="button" value="Add Class" class="buttonFaddclass" />
<input type="button" value="Remove Class" class="buttonFremoveclass" />
<a href="#" class="codeButtonF">Show / Hide jquery code</a>
<pre class="codeF"><code class="javascript">//Code for example F
$("input.buttonFaddclass").click(function(){ $("p.firstparagraph").addClass("changeP"); });
$("input.buttonFremoveclass").click(function(){ $("p.firstparagraph").removeClass("changeP"); });
//show code example F
$("a.codeButtonF").click(function(){$("pre.codeF").toggle()});
</code></pre>
<hr size="1" noshade="noshade" color="#e8e8e8" />
</div>
<div style="float:right;width:60%;height:100%;background-color:#e8e8e8;min-height:900px" class="contentToChange">
<h2 style="margin-left:30px;">Column 2:</h2>
<p class="alert">Use the buttons to the left in the examples to run JQuery code on the structural markup below. Showing the code for each example will display the javascript required for the input buttons, the changes to the structural markup below, and the hide / show feature in the examples.</p>
<p class="firstparagraph">Lorem ipsum <em>dolor</em> sit amet, consectetuer <em>adipiscing</em> elit, sed diam nonummy nibh euismod <em>tincidunt</em> ut laoreet dolore magna aliquam erat <strong>volutpat</strong>. Ut wisi enim ad minim <em>veniam</em>, quis nostrud exerci <strong>tation</strong> ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
<p class="secondparagraph">Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse <strong>molestie</strong> consequat, vel illum <strong>dolore</strong> eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer <strong>adipiscing</strong> elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
<p class="thridparagraph">Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea <em>commodo</em> consequat. Duis autem vel eum iriure dolor in hendrerit in <em>vulputate</em> velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te <strong>feugait</strong> nulla facilisi.</p>
<p class="fourthparagraph">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, <strong>quis</strong> nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
Duis autem vel eum iriure dolor in <em>hendrerit</em> in vulputate velit <em>esse</em> molestie consequat, vel illum dolore eu feugiat nulla <strong>facilisis</strong> at vero eros et accumsan et <em>iusto</em> odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te <strong>feugait</strong> nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh <strong>euismod</strong> tincidunt ut laoreet <em>dolore</em> magna aliquam erat volutpat.</p>
<p class="fifthparagraph">Lorem ipsum <em>dolor</em> sit amet, consectetuer <em>adipiscing</em> elit, sed diam nonummy nibh euismod <em>tincidunt</em> ut laoreet dolore magna aliquam erat <strong>volutpat</strong>. Ut wisi enim ad minim <em>veniam</em>, quis nostrud exerci <strong>tation</strong> ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
<p class="sixthparagraph">Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse <strong>molestie</strong> consequat, vel illum <strong>dolore</strong> eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer <strong>adipiscing</strong> elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
</div>
</body>
</html>