1 test("text()", function() {
3 var expected = "This link has class=\"blog\": Simon Willison's Weblog";
4 equals( jQuery('#sap').text(), expected, 'Check for merged text of more then one element.' );
7 test("wrap(String|Element)", function() {
9 var defaultText = 'Try them out:'
10 var result = jQuery('#first').wrap('<div class="red"><span></span></div>').text();
11 equals( defaultText, result, 'Check for wrapping of on-the-fly html' );
12 ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
15 var defaultText = 'Try them out:'
16 var result = jQuery('#first').wrap(document.getElementById('empty')).parent();
17 ok( result.is('ol'), 'Check for element wrapping' );
18 equals( result.text(), defaultText, 'Check for element wrapping' );
21 jQuery('#check1').click(function() {
23 ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
24 jQuery(checkbox).wrap( '<div id="c1" style="display:none;"></div>' );
25 ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
28 // using contents will get comments regular, text, and comment nodes
29 var j = jQuery("#nonnodes").contents();
31 equals( jQuery("#nonnodes > i").length, 3, "Check node,textnode,comment wraps ok" );
32 equals( jQuery("#nonnodes > i").text(), j.text() + j[1].nodeValue, "Check node,textnode,comment wraps doesn't hurt text" );
34 // Try wrapping a disconnected node
35 j = jQuery("<label/>").wrap("<li/>");
36 equals( j[0].nodeName.toUpperCase(), "LABEL", "Element is a label" );
37 equals( j[0].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
40 test("wrapAll(String|Element)", function() {
42 var prev = jQuery("#firstp")[0].previousSibling;
43 var p = jQuery("#firstp,#first")[0].parentNode;
44 var result = jQuery('#firstp,#first').wrapAll('<div class="red"><div id="tmp"></div></div>');
45 equals( result.parent().length, 1, 'Check for wrapping of on-the-fly html' );
46 ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
47 ok( jQuery('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
48 equals( jQuery("#first").parent().parent()[0].previousSibling, prev, "Correct Previous Sibling" );
49 equals( jQuery("#first").parent().parent()[0].parentNode, p, "Correct Parent" );
52 var prev = jQuery("#firstp")[0].previousSibling;
53 var p = jQuery("#first")[0].parentNode;
54 var result = jQuery('#firstp,#first').wrapAll(document.getElementById('empty'));
55 equals( jQuery("#first").parent()[0], jQuery("#firstp").parent()[0], "Same Parent" );
56 equals( jQuery("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );
57 equals( jQuery("#first").parent()[0].parentNode, p, "Correct Parent" );
60 test("wrapInner(String|Element)", function() {
62 var num = jQuery("#first").children().length;
63 var result = jQuery('#first').wrapInner('<div class="red"><div id="tmp"></div></div>');
64 equals( jQuery("#first").children().length, 1, "Only one child" );
65 ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
66 equals( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
69 var num = jQuery("#first").children().length;
70 var result = jQuery('#first').wrapInner(document.getElementById('empty'));
71 equals( jQuery("#first").children().length, 1, "Only one child" );
72 ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
73 equals( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
76 test("append(String|Element|Array<Element>|jQuery)", function() {
78 var defaultText = 'Try them out:'
79 var result = jQuery('#first').append('<b>buga</b>');
80 equals( result.text(), defaultText + 'buga', 'Check if text appending works' );
81 equals( jQuery('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
84 var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
85 jQuery('#sap').append(document.getElementById('first'));
86 equals( expected, jQuery('#sap').text(), "Check for appending of element" );
89 expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
90 jQuery('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);
91 equals( expected, jQuery('#sap').text(), "Check for appending of array of elements" );
94 expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
95 jQuery('#sap').append(jQuery("#first, #yahoo"));
96 equals( expected, jQuery('#sap').text(), "Check for appending of jQuery object" );
99 jQuery("#sap").append( 5 );
100 ok( jQuery("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );
103 jQuery("#sap").append( " text with spaces " );
104 ok( jQuery("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );
107 ok( jQuery("#sap").append([]), "Check for appending an empty array." );
108 ok( jQuery("#sap").append(""), "Check for appending an empty string." );
109 ok( jQuery("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );
112 jQuery("#sap").append(document.getElementById('form'));
113 equals( jQuery("#sap>form").size(), 1, "Check for appending a form" ); // Bug #910
118 jQuery( jQuery("#iframe")[0].contentWindow.document.body ).append("<div>test</div>");
123 ok( pass, "Test for appending a DOM node to the contents of an IFrame" );
126 jQuery('<fieldset/>').appendTo('#form').append('<legend id="legend">test</legend>');
127 t( 'Append legend', '#legend', ['legend'] );
130 jQuery('#select1').append('<OPTION>Test</OPTION>');
131 equals( jQuery('#select1 option:last').text(), "Test", "Appending <OPTION> (all caps)" );
133 jQuery('#table').append('<colgroup></colgroup>');
134 ok( jQuery('#table colgroup').length, "Append colgroup" );
136 jQuery('#table colgroup').append('<col/>');
137 ok( jQuery('#table colgroup col').length, "Append col" );
140 jQuery('#table').append('<caption></caption>');
141 ok( jQuery('#table caption').length, "Append caption" );
145 .append('<select id="appendSelect1"></select>')
146 .append('<select id="appendSelect2"><option>Test</option></select>');
148 t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );
150 // using contents will get comments regular, text, and comment nodes
151 var j = jQuery("#nonnodes").contents();
152 var d = jQuery("<div/>").appendTo("#nonnodes").append(j);
153 equals( jQuery("#nonnodes").length, 1, "Check node,textnode,comment append moved leaving just the div" );
154 ok( d.contents().length >= 2, "Check node,textnode,comment append works" );
155 d.contents().appendTo("#nonnodes");
157 ok( jQuery("#nonnodes").contents().length >= 2, "Check node,textnode,comment append cleanup worked" );
160 test("appendTo(String|Element|Array<Element>|jQuery)", function() {
162 var defaultText = 'Try them out:'
163 jQuery('<b>buga</b>').appendTo('#first');
164 equals( jQuery("#first").text(), defaultText + 'buga', 'Check if text appending works' );
165 equals( jQuery('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
168 var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
169 jQuery(document.getElementById('first')).appendTo('#sap');
170 equals( expected, jQuery('#sap').text(), "Check for appending of element" );
173 expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
174 jQuery([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');
175 equals( expected, jQuery('#sap').text(), "Check for appending of array of elements" );
178 ok( jQuery(document.createElement("script")).appendTo("body").length, "Make sure a disconnected script can be appended." );
181 expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
182 jQuery("#first, #yahoo").appendTo('#sap');
183 equals( expected, jQuery('#sap').text(), "Check for appending of jQuery object" );
186 jQuery('#select1').appendTo('#foo');
187 t( 'Append select', '#foo select', ['select1'] );
190 var div = jQuery("<div/>").click(function(){
191 ok(true, "Running a cloned click.");
193 div.appendTo("#main, #moretests");
195 jQuery("#main div:last").click();
196 jQuery("#moretests div:last").click();
199 var div = jQuery("<div/>").appendTo("#main, #moretests");
201 equals( div.length, 2, "appendTo returns the inserted elements" );
203 div.addClass("test");
205 ok( jQuery("#main div:last").hasClass("test"), "appendTo element was modified after the insertion" );
206 ok( jQuery("#moretests div:last").hasClass("test"), "appendTo element was modified after the insertion" );
211 test("prepend(String|Element|Array<Element>|jQuery)", function() {
213 var defaultText = 'Try them out:'
214 var result = jQuery('#first').prepend('<b>buga</b>');
215 equals( result.text(), 'buga' + defaultText, 'Check if text prepending works' );
216 equals( jQuery('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
219 var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
220 jQuery('#sap').prepend(document.getElementById('first'));
221 equals( expected, jQuery('#sap').text(), "Check for prepending of element" );
224 expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
225 jQuery('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);
226 equals( expected, jQuery('#sap').text(), "Check for prepending of array of elements" );
229 expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
230 jQuery('#sap').prepend(jQuery("#first, #yahoo"));
231 equals( expected, jQuery('#sap').text(), "Check for prepending of jQuery object" );
234 test("prependTo(String|Element|Array<Element>|jQuery)", function() {
236 var defaultText = 'Try them out:'
237 jQuery('<b>buga</b>').prependTo('#first');
238 equals( jQuery('#first').text(), 'buga' + defaultText, 'Check if text prepending works' );
239 equals( jQuery('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
242 var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
243 jQuery(document.getElementById('first')).prependTo('#sap');
244 equals( expected, jQuery('#sap').text(), "Check for prepending of element" );
247 expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
248 jQuery([document.getElementById('first'), document.getElementById('yahoo')]).prependTo('#sap');
249 equals( expected, jQuery('#sap').text(), "Check for prepending of array of elements" );
252 expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
253 jQuery("#first, #yahoo").prependTo('#sap');
254 equals( expected, jQuery('#sap').text(), "Check for prepending of jQuery object" );
257 jQuery('<select id="prependSelect1"></select>').prependTo('form:last');
258 jQuery('<select id="prependSelect2"><option>Test</option></select>').prependTo('form:last');
260 t( "Prepend Select", "#prependSelect2, #prependSelect1", ["prependSelect2", "prependSelect1"] );
263 test("before(String|Element|Array<Element>|jQuery)", function() {
265 var expected = 'This is a normal link: bugaYahoo';
266 jQuery('#yahoo').before('<b>buga</b>');
267 equals( expected, jQuery('#en').text(), 'Insert String before' );
270 expected = "This is a normal link: Try them out:Yahoo";
271 jQuery('#yahoo').before(document.getElementById('first'));
272 equals( expected, jQuery('#en').text(), "Insert element before" );
275 expected = "This is a normal link: Try them out:diveintomarkYahoo";
276 jQuery('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);
277 equals( expected, jQuery('#en').text(), "Insert array of elements before" );
280 expected = "This is a normal link: diveintomarkTry them out:Yahoo";
281 jQuery('#yahoo').before(jQuery("#first, #mark"));
282 equals( expected, jQuery('#en').text(), "Insert jQuery before" );
285 test("insertBefore(String|Element|Array<Element>|jQuery)", function() {
287 var expected = 'This is a normal link: bugaYahoo';
288 jQuery('<b>buga</b>').insertBefore('#yahoo');
289 equals( expected, jQuery('#en').text(), 'Insert String before' );
292 expected = "This is a normal link: Try them out:Yahoo";
293 jQuery(document.getElementById('first')).insertBefore('#yahoo');
294 equals( expected, jQuery('#en').text(), "Insert element before" );
297 expected = "This is a normal link: Try them out:diveintomarkYahoo";
298 jQuery([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');
299 equals( expected, jQuery('#en').text(), "Insert array of elements before" );
302 expected = "This is a normal link: diveintomarkTry them out:Yahoo";
303 jQuery("#first, #mark").insertBefore('#yahoo');
304 equals( expected, jQuery('#en').text(), "Insert jQuery before" );
307 test("after(String|Element|Array<Element>|jQuery)", function() {
309 var expected = 'This is a normal link: Yahoobuga';
310 jQuery('#yahoo').after('<b>buga</b>');
311 equals( expected, jQuery('#en').text(), 'Insert String after' );
314 expected = "This is a normal link: YahooTry them out:";
315 jQuery('#yahoo').after(document.getElementById('first'));
316 equals( expected, jQuery('#en').text(), "Insert element after" );
319 expected = "This is a normal link: YahooTry them out:diveintomark";
320 jQuery('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);
321 equals( expected, jQuery('#en').text(), "Insert array of elements after" );
324 expected = "This is a normal link: YahoodiveintomarkTry them out:";
325 jQuery('#yahoo').after(jQuery("#first, #mark"));
326 equals( expected, jQuery('#en').text(), "Insert jQuery after" );
329 test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
331 var expected = 'This is a normal link: Yahoobuga';
332 jQuery('<b>buga</b>').insertAfter('#yahoo');
333 equals( expected, jQuery('#en').text(), 'Insert String after' );
336 expected = "This is a normal link: YahooTry them out:";
337 jQuery(document.getElementById('first')).insertAfter('#yahoo');
338 equals( expected, jQuery('#en').text(), "Insert element after" );
341 expected = "This is a normal link: YahooTry them out:diveintomark";
342 jQuery([document.getElementById('first'), document.getElementById('mark')]).insertAfter('#yahoo');
343 equals( expected, jQuery('#en').text(), "Insert array of elements after" );
346 expected = "This is a normal link: YahoodiveintomarkTry them out:";
347 jQuery("#first, #mark").insertAfter('#yahoo');
348 equals( expected, jQuery('#en').text(), "Insert jQuery after" );
351 test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
353 jQuery('#yahoo').replaceWith('<b id="replace">buga</b>');
354 ok( jQuery("#replace")[0], 'Replace element with string' );
355 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
358 jQuery('#yahoo').replaceWith(document.getElementById('first'));
359 ok( jQuery("#first")[0], 'Replace element with element' );
360 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );
363 jQuery('#yahoo').replaceWith([document.getElementById('first'), document.getElementById('mark')]);
364 ok( jQuery("#first")[0], 'Replace element with array of elements' );
365 ok( jQuery("#mark")[0], 'Replace element with array of elements' );
366 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
369 jQuery('#yahoo').replaceWith(jQuery("#first, #mark"));
370 ok( jQuery("#first")[0], 'Replace element with set of elements' );
371 ok( jQuery("#mark")[0], 'Replace element with set of elements' );
372 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
375 test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
377 jQuery('<b id="replace">buga</b>').replaceAll("#yahoo");
378 ok( jQuery("#replace")[0], 'Replace element with string' );
379 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
382 jQuery(document.getElementById('first')).replaceAll("#yahoo");
383 ok( jQuery("#first")[0], 'Replace element with element' );
384 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );
387 jQuery([document.getElementById('first'), document.getElementById('mark')]).replaceAll("#yahoo");
388 ok( jQuery("#first")[0], 'Replace element with array of elements' );
389 ok( jQuery("#mark")[0], 'Replace element with array of elements' );
390 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
393 jQuery("#first, #mark").replaceAll("#yahoo");
394 ok( jQuery("#first")[0], 'Replace element with set of elements' );
395 ok( jQuery("#mark")[0], 'Replace element with set of elements' );
396 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
399 test("clone()", function() {
401 equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Assert text for #en' );
402 var clone = jQuery('#yahoo').clone();
403 equals( 'Try them out:Yahoo', jQuery('#first').append(clone).text(), 'Check for clone' );
404 equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Reassert text for #en' );
407 "<table/>", "<tr/>", "<td/>", "<div/>",
408 "<button/>", "<ul/>", "<ol/>", "<li/>",
409 "<input type='checkbox' />", "<select/>", "<option/>", "<textarea/>",
410 "<tbody/>", "<thead/>", "<tfoot/>", "<iframe/>"
412 for (var i = 0; i < cloneTags.length; i++) {
413 var j = jQuery(cloneTags[i]);
414 equals( j[0].tagName, j.clone()[0].tagName, 'Clone a <' + cloneTags[i].substring(1));
417 // using contents will get comments regular, text, and comment nodes
418 var cl = jQuery("#nonnodes").contents().clone();
419 ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
421 var div = jQuery("<div><ul><li>test</li></ul></div>").click(function(){
422 ok( true, "Bound event still exists." );
425 div = div.clone(true).clone(true);
426 equals( div.length, 1, "One element cloned" );
427 equals( div[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
428 div.trigger("click");
430 div = jQuery("<div/>").append([ document.createElement("table"), document.createElement("table") ]);
431 div.find("table").click(function(){
432 ok( true, "Bound event still exists." );
435 div = div.clone(true);
436 equals( div.length, 1, "One element cloned" );
437 equals( div[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
438 div.find("table:last").trigger("click");
440 div = jQuery("<div/>").html('<object height="355" width="425"> <param name="movie" value="http://www.youtube.com/v/JikaHBDoV3k&hl=en"> <param name="wmode" value="transparent"> </object>');
442 div = div.clone(true);
443 equals( div.length, 1, "One element cloned" );
444 equals( div[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
448 test("clone() on XML nodes", function() {
451 jQuery.get("data/dashboard.xml", function (xml) {
452 var root = jQuery(xml.documentElement).clone();
453 var origTab = jQuery("tab", xml).eq(0);
454 var cloneTab = jQuery("tab", root).eq(0);
455 origTab.text("origval");
456 cloneTab.text("cloneval");
457 equals(origTab.text(), "origval", "Check original XML node was correctly set");
458 equals(cloneTab.text(), "cloneval", "Check cloned XML node was correctly set");
464 test("val()", function() {
467 equals( jQuery("#text1").val(), "Test", "Check for value of input element" );
468 // ticket #1714 this caused a JS error in IE
469 equals( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" );
470 ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );
472 equals( jQuery('#select2').val(), '3', 'Call val() on a single="single" select' );
474 isSet( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' );
476 equals( jQuery('#option3c').val(), '2', 'Call val() on a option element with value' );
478 equals( jQuery('#option3a').val(), '', 'Call val() on a option element with empty value' );
480 equals( jQuery('#option3e').val(), 'no value', 'Call val() on a option element with no value attribute' );
484 test("val(String/Number)", function() {
486 document.getElementById('text1').value = "bla";
487 equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
489 jQuery("#text1").val('test');
490 equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" );
492 jQuery("#text1").val(67);
493 equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" );
495 jQuery("#select1").val("3");
496 equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
498 jQuery("#select1").val(2);
499 equals( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" );
501 // using contents will get comments regular, text, and comment nodes
502 var j = jQuery("#nonnodes").contents();
504 equals( j.val(), "asdf", "Check node,textnode,comment with val()" );
505 j.removeAttr("value");
508 test("html(String)", function() {
511 jQuery.scriptorder = 0;
513 var div = jQuery("#main > div");
514 div.html("<b>test</b>");
516 for ( var i = 0; i < div.size(); i++ ) {
517 if ( div.get(i).childNodes.length != 1 ) pass = false;
519 ok( pass, "Set HTML" );
522 // using contents will get comments regular, text, and comment nodes
523 var j = jQuery("#nonnodes").contents();
524 j.html("<b>bold</b>");
526 // this is needed, or the expando added by jQuery unique will yield a different html
527 j.find('b').removeData();
528 equals( j.html().replace(/ xmlns="[^"]+"/g, "").toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" );
530 jQuery("#main").html("<select/>");
531 jQuery("#main select").html("<option>O1</option><option selected='selected'>O2</option><option>O3</option>");
532 equals( jQuery("#main select").val(), "O2", "Selected option correct" );
534 var $div = jQuery('<div />');
535 equals( $div.html( 5 ).html(), '5', 'Setting a number as html' );
536 equals( $div.html( 0 ).html(), '0', 'Setting a zero as html' );
540 jQuery("#main").html('<script type="something/else">ok( false, "Non-script evaluated." );</script><script type="text/javascript">ok( true, "text/javascript is evaluated." );</script><script>ok( true, "No type is evaluated." );</script><div><script type="text/javascript">ok( true, "Inner text/javascript is evaluated." );</script><script>ok( true, "Inner No type is evaluated." );</script><script type="something/else">ok( false, "Non-script evaluated." );</script></div>');
544 jQuery("#main").html('<script type="text/javascript">ok( true, "jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script>');
546 jQuery("#main").html('foo <form><script type="text/javascript">ok( true, "jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script></form>');
548 // it was decided that waiting to execute ALL scripts makes sense since nested ones have to wait anyway so this test case is changed, see #1959
549 jQuery("#main").html("<script>equals(jQuery.scriptorder++, 0, 'Script is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html (even though appears before)')<\/script><span id='scriptorder'><script>equals(jQuery.scriptorder++, 1, 'Script (nested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script></span><script>equals(jQuery.scriptorder++, 2, 'Script (unnested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script>");
551 setTimeout( start, 100 );
554 test("text(String)", function() {
556 equals( jQuery("#foo").text("<div><b>Hello</b> cruel world!</div>")[0].innerHTML.replace(/>/g, ">"), "<div><b>Hello</b> cruel world!</div>", "Check escaped text" );
558 // using contents will get comments regular, text, and comment nodes
559 var j = jQuery("#nonnodes").contents();
561 equals( jQuery(j[0]).text(), "hi!", "Check node,textnode,comment with text()" );
562 equals( j[1].nodeValue, " there ", "Check node,textnode,comment with text()" );
563 equals( j[2].nodeType, 8, "Check node,textnode,comment with text()" );
566 test("remove()", function() {
568 jQuery("#ap").children().remove();
569 ok( jQuery("#ap").text().length > 10, "Check text is not removed" );
570 equals( jQuery("#ap").children().length, 0, "Check remove" );
573 jQuery("#ap").children().remove("a");
574 ok( jQuery("#ap").text().length > 10, "Check text is not removed" );
575 equals( jQuery("#ap").children().length, 1, "Check filtered remove" );
577 jQuery("#ap").children().remove("a, code");
578 equals( jQuery("#ap").children().length, 0, "Check multi-filtered remove" );
580 // using contents will get comments regular, text, and comment nodes
581 equals( jQuery("#nonnodes").contents().length, 3, "Check node,textnode,comment remove works" );
582 jQuery("#nonnodes").contents().remove();
583 equals( jQuery("#nonnodes").contents().length, 0, "Check node,textnode,comment remove works" );
586 test("empty()", function() {
588 equals( jQuery("#ap").children().empty().text().length, 0, "Check text is removed" );
589 equals( jQuery("#ap").children().length, 4, "Check elements are not removed" );
591 // using contents will get comments regular, text, and comment nodes
592 var j = jQuery("#nonnodes").contents();
594 equals( j.html(), "", "Check node,textnode,comment empty works" );