Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
5d0b503c
Commit
5d0b503c
authored
Jul 28, 2006
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added my one fun thing for the night: jQuery.each, inspired by Dean Edwards' work.
parent
efe0fef8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
26 deletions
+24
-26
jquery.js
jquery/jquery.js
+24
-26
No files found.
jquery/jquery.js
View file @
5d0b503c
...
@@ -196,13 +196,7 @@ jQuery.fn = jQuery.prototype = {
...
@@ -196,13 +196,7 @@ jQuery.fn = jQuery.prototype = {
* @param Function fn A function to execute
* @param Function fn A function to execute
*/
*/
each
:
function
(
fn
,
args
)
{
each
:
function
(
fn
,
args
)
{
// Iterate through all of the matched elements
return
jQuery
.
each
(
this
,
fn
,
args
);
for
(
var
i
=
0
;
i
<
this
.
length
;
i
++
)
// Execute the function within the context of each element
fn
.
apply
(
this
[
i
],
args
||
[
i
]
);
return
this
;
},
},
/**
/**
...
@@ -669,11 +663,10 @@ jQuery.fn = jQuery.prototype = {
...
@@ -669,11 +663,10 @@ jQuery.fn = jQuery.prototype = {
}
else
}
else
obj
=
tbody
[
0
];
obj
=
tbody
[
0
];
}
}
//alert( obj );
for
(
var
i
=
(
dir
<
0
?
a
.
length
-
1
:
0
);
for
(
var
i
=
(
dir
<
0
?
a
.
length
-
1
:
0
);
i
!=
(
dir
<
0
?
dir
:
a
.
length
);
i
+=
dir
)
{
i
!=
(
dir
<
0
?
dir
:
a
.
length
);
i
+=
dir
)
{
fn
.
apply
(
obj
,
[
clone
?
a
[
i
].
cloneNode
(
true
)
:
a
[
i
]
]
);
fn
.
apply
(
obj
,
[
clone
?
a
[
i
].
cloneNode
(
true
)
:
a
[
i
]
]
);
//alert( fn );
}
}
});
});
},
},
...
@@ -716,21 +709,18 @@ jQuery.extend({
...
@@ -716,21 +709,18 @@ jQuery.extend({
init
:
function
(){
init
:
function
(){
jQuery
.
initDone
=
true
;
jQuery
.
initDone
=
true
;
for
(
var
i
in
jQuery
.
macros
.
axis
)
new
function
(){
jQuery
.
each
(
jQuery
.
macros
.
axis
,
function
(
i
,
n
){
var
t
=
jQuery
.
macros
.
axis
[
i
];
jQuery
.
fn
[
i
]
=
function
(
a
)
{
jQuery
.
fn
[
i
]
=
function
(
a
)
{
var
ret
=
jQuery
.
map
(
this
,
t
);
var
ret
=
jQuery
.
map
(
this
,
n
);
if
(
a
&&
a
.
constructor
==
String
)
if
(
a
&&
a
.
constructor
==
String
)
ret
=
jQuery
.
filter
(
a
,
ret
).
r
;
ret
=
jQuery
.
filter
(
a
,
ret
).
r
;
return
this
.
pushStack
(
ret
,
arguments
);
return
this
.
pushStack
(
ret
,
arguments
);
};
};
};
}
)
;
// appendTo, prependTo, beforeTo, afterTo
// appendTo, prependTo, beforeTo, afterTo
for
(
var
i
=
0
;
i
<
jQuery
.
macros
.
to
.
length
;
i
++
)
new
function
(){
jQuery
.
each
(
jQuery
.
macros
.
to
,
function
(
i
,
n
){
var
n
=
jQuery
.
macros
.
to
[
i
];
jQuery
.
fn
[
n
+
"To"
]
=
function
(){
jQuery
.
fn
[
n
+
"To"
]
=
function
(){
var
a
=
arguments
;
var
a
=
arguments
;
return
this
.
each
(
function
(){
return
this
.
each
(
function
(){
...
@@ -738,33 +728,41 @@ jQuery.extend({
...
@@ -738,33 +728,41 @@ jQuery.extend({
$
(
a
[
i
])[
n
](
this
);
$
(
a
[
i
])[
n
](
this
);
});
});
};
};
};
}
)
;
for
(
var
i
in
jQuery
.
macros
.
each
)
new
function
()
{
jQuery
.
each
(
jQuery
.
macros
.
each
,
function
(
i
,
n
){
var
n
=
jQuery
.
macros
.
each
[
i
];
jQuery
.
fn
[
i
]
=
function
()
{
jQuery
.
fn
[
i
]
=
function
()
{
return
this
.
each
(
n
,
arguments
);
return
this
.
each
(
n
,
arguments
);
};
};
};
}
)
;
for
(
var
i
in
jQuery
.
macros
.
attr
)
new
function
()
{
jQuery
.
each
(
jQuery
.
macros
.
attr
,
function
(
i
,
n
)
{
var
n
=
jQuery
.
macros
.
attr
[
i
]
||
i
;
n
=
n
||
i
;
jQuery
.
fn
[
i
]
=
function
(
h
)
{
jQuery
.
fn
[
i
]
=
function
(
h
)
{
return
h
==
undefined
?
return
h
==
undefined
?
this
.
length
?
this
[
0
][
n
]
:
null
:
this
.
length
?
this
[
0
][
n
]
:
null
:
this
.
attr
(
n
,
h
);
this
.
attr
(
n
,
h
);
};
};
};
}
)
;
for
(
var
i
=
0
;
i
<
jQuery
.
macros
.
css
.
length
;
i
++
)
new
function
()
{
jQuery
.
each
(
jQuery
.
macros
.
css
,
function
(
i
,
n
){
var
n
=
jQuery
.
macros
.
css
[
i
];
jQuery
.
fn
[
i
]
=
function
(
h
)
{
jQuery
.
fn
[
i
]
=
function
(
h
)
{
return
h
==
undefined
?
return
h
==
undefined
?
(
this
.
length
?
jQuery
.
css
(
this
[
0
],
n
)
:
null
)
:
(
this
.
length
?
jQuery
.
css
(
this
[
0
],
n
)
:
null
)
:
this
.
css
(
n
,
h
);
this
.
css
(
n
,
h
);
};
};
};
});
},
each
:
function
(
obj
,
fn
,
args
)
{
if
(
obj
.
length
==
undefined
)
for
(
var
i
in
obj
)
fn
.
apply
(
obj
[
i
],
args
||
[
i
,
obj
[
i
]]
);
else
for
(
var
i
=
0
;
i
<
obj
.
length
;
i
++
)
fn
.
apply
(
obj
[
i
],
args
||
[
i
,
obj
[
i
]]
);
return
obj
;
},
},
className
:
{
className
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment