diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index 1c81e080..e587c3a0 100644 --- a/src/jquery/coreTest.js +++ b/src/jquery/coreTest.js @@ -35,6 +35,10 @@ test("add(String|Element|Array)", function() { var x = $([]).add($("
xxx
")).add($("xxx
")); ok( x[0].id == "x1", "Check on-the-fly element1" ); ok( x[1].id == "x2", "Check on-the-fly element2" ); + + var x = $([]).add("xxx
").add("xxx
"); + ok( x[0].id == "x1", "Check on-the-fly element1" ); + ok( x[1].id == "x2", "Check on-the-fly element2" ); }); test("each(Function)", function() { diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 0aac0262..0f712afd 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -930,6 +930,19 @@ jQuery.fn = jQuery.prototype = { * @param String expr An expression whose matched elements are added * @cat DOM/Traversing */ + + /** + * Adds the on the fly created elements to the jQuery object. + * + * @example $("p").add("Again") + * @beforeHello
+ * @result [Hello
, Again ] + * + * @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. @@ -952,7 +965,7 @@ jQuery.fn = jQuery.prototype = { add: function(t) { return this.set( jQuery.merge( this.get(), - typeof t == "string" ? jQuery.find(t) : t ) + typeof t == "string" ? jQuery(t).get() : t ) ); },