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
caad7f81
Commit
caad7f81
authored
Jan 10, 2007
by
Jörn Zaefferer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed add to also create HTML on-the-fly by using jQuery() instead of jQuery.find()
parent
a5f9108a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
coreTest.js
src/jquery/coreTest.js
+4
-0
jquery.js
src/jquery/jquery.js
+14
-1
No files found.
src/jquery/coreTest.js
View file @
caad7f81
...
@@ -35,6 +35,10 @@ test("add(String|Element|Array)", function() {
...
@@ -35,6 +35,10 @@ test("add(String|Element|Array)", function() {
var
x
=
$
([]).
add
(
$
(
"<p id='x1'>xxx</p>"
)).
add
(
$
(
"<p id='x2'>xxx</p>"
));
var
x
=
$
([]).
add
(
$
(
"<p id='x1'>xxx</p>"
)).
add
(
$
(
"<p id='x2'>xxx</p>"
));
ok
(
x
[
0
].
id
==
"x1"
,
"Check on-the-fly element1"
);
ok
(
x
[
0
].
id
==
"x1"
,
"Check on-the-fly element1"
);
ok
(
x
[
1
].
id
==
"x2"
,
"Check on-the-fly element2"
);
ok
(
x
[
1
].
id
==
"x2"
,
"Check on-the-fly element2"
);
var
x
=
$
([]).
add
(
"<p id='x1'>xxx</p>"
).
add
(
"<p id='x2'>xxx</p>"
);
ok
(
x
[
0
].
id
==
"x1"
,
"Check on-the-fly element1"
);
ok
(
x
[
1
].
id
==
"x2"
,
"Check on-the-fly element2"
);
});
});
test
(
"each(Function)"
,
function
()
{
test
(
"each(Function)"
,
function
()
{
...
...
src/jquery/jquery.js
View file @
caad7f81
...
@@ -931,6 +931,19 @@ jQuery.fn = jQuery.prototype = {
...
@@ -931,6 +931,19 @@ jQuery.fn = jQuery.prototype = {
* @cat DOM/Traversing
* @cat DOM/Traversing
*/
*/
/**
* Adds the on the fly created elements to the jQuery object.
*
* @example $("p").add("<span>Again</span>")
* @before <p>Hello</p>
* @result [ <p>Hello</p>, <span>Again</span> ]
*
* @name add
* @type jQuery
* @param String html A string of HTML to create on the fly.
* @cat DOM/Traversing
*/
/**
/**
* Adds one or more Elements to the set of matched elements.
* Adds one or more Elements to the set of matched elements.
*
*
...
@@ -952,7 +965,7 @@ jQuery.fn = jQuery.prototype = {
...
@@ -952,7 +965,7 @@ jQuery.fn = jQuery.prototype = {
add
:
function
(
t
)
{
add
:
function
(
t
)
{
return
this
.
set
(
jQuery
.
merge
(
return
this
.
set
(
jQuery
.
merge
(
this
.
get
(),
this
.
get
(),
typeof
t
==
"string"
?
jQuery
.
find
(
t
)
:
t
)
typeof
t
==
"string"
?
jQuery
(
t
).
get
(
)
:
t
)
);
);
},
},
...
...
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