forked from ghosert/VimProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTutorials.html
More file actions
executable file
·143 lines (107 loc) · 3.58 KB
/
Copy pathTutorials.html
File metadata and controls
executable file
·143 lines (107 loc) · 3.58 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="jquery-libs/jquery-1.4.4.js"></script>
<style type="text/css">
a.test { font-weight: bold; }
</style>
<script type="text/javascript">
// PartI Begin: How JQuery Works
// Use $(document).ready() instead of window.onload() to launch code. It starts when dom loading is completed,
// ignore the other stuffs like images loading compared with window.onload().
$(document).ready(function ()
{
// Add click handler(event handler binding) for "<a>" tag link.
$('a#part1').click(function(event)
{
alert('hello');
// Means 'return false;' in event handler, so that this will prevent default behaviour.
event.preventDefault();
// Adding and Removing a CSS Class
// (CSS allows multiple classes to be added to an element.)
if ($('a#part1').hasClass('test')) {
$('a#part1').removeClass('test');
} else {
$('a#part1').addClass('test');
}
});
// Special Effects
$('div#part1').click(function (event)
{
$(this).hide('slow');
});
// Callback without arguments
function myCallBack()
{
alert("I'm myCallBack method.");
}
// $ here means: $ === jQuery. $.get() means jQuery.get() is a ajax call, and support to read local file... cool.
$.get('my.html', myCallBack);
// Callback with arguments
function myCallBack2(data, textStatus)
{
alert(data);
alert("Status:" + textStatus + " I'm myCallBack2 method.");
}
$.get('my.html', function (data, textStatus)
{
myCallBack2(data, textStatus);
});
// PartI End: How JQuery Works
// PartII Begin: jQueryForDesigners
$(".article .thebody").hide();
$("#container .article ul")
.prepend("<li class='readbody'><a href='' title='Read the article'>Read Body</a></li>");
$(".actions li.readbody a").click(function(event){
$(this).parents("ul").prev(".thebody").toggle();
// Stop the link click from doing its normal thing
event.preventDefault();
});
});
// PartII End: jQueryForDesigners
</script>
<!-- PartII Begin: jQueryForDesigners -->
<script>
$(function ()
{
$('dd label').append(': The colon is appended by jQuery.');
$('dd label').prepend('* The star is prepended by jQuery.');
});
</script>
<!-- PartII End: jQueryForDesigners -->
</head>
<body>
<p><b>PartI: How JQuery Works:</b></p>
<a id="part1" href="http://jquery.com/">jQuery</a>
<div id="part1">Click Me To Hide Me.</div>
<p><b>PartII : jQueryForDesigners:</b></p>
<dl>
<dt>Hello</dt>
<dd><label>Jiawei</label></dd>
<dt>Hello</dt>
<dd><label>World</label></dd>
</dl>
<div id="container">
<div class="article">
<h3>Title 01</h3>
<p class="summary">Summary 01</p>
<p class="thebody">Lorem ipsum....</p>
<ul class="actions">
<li><a href="" onclick="return false;">comment</a></li>
<li><a href="" onclick="return false;">Trackback</a></li>
</ul>
</div>
<div class="article">
<h3>Title 02</h3>
<p class="summary">Summary 02</p>
<p class="thebody">Lorem ipsum....</p>
<ul class="actions">
<li><a href="" onclick="return false;">comment</a></li>
<li><a href="" onclick="return false;">Trackback</a></li>
</ul>
</div>
</div>
<p><b>PartIII Using jQuery with Other Libraries:</b></p>
<a href="http://docs.jquery.com/Using_jQuery_with_Other_Libraries">Using jQuery with Other Libraries</a>
</body>
</html>