3 var bareObj = function(value) { return value; };
4 var functionReturningObj = function(value) { return (function() { return value; }); };
6 test("attr(String)", function() {
9 // This one sometimes fails randomly ?!
10 equals( jQuery('#text1').attr('value'), "Test", 'Check for value attribute' );
12 equals( jQuery('#text1').attr('value', "Test2").attr('defaultValue'), "Test", 'Check for defaultValue attribute' );
13 equals( jQuery('#text1').attr('type'), "text", 'Check for type attribute' );
14 equals( jQuery('#radio1').attr('type'), "radio", 'Check for type attribute' );
15 equals( jQuery('#check1').attr('type'), "checkbox", 'Check for type attribute' );
16 equals( jQuery('#simon1').attr('rel'), "bookmark", 'Check for rel attribute' );
17 equals( jQuery('#google').attr('title'), "Google!", 'Check for title attribute' );
18 equals( jQuery('#mark').attr('hreflang'), "en", 'Check for hreflang attribute' );
19 equals( jQuery('#en').attr('lang'), "en", 'Check for lang attribute' );
20 equals( jQuery('#simon').attr('class'), "blog link", 'Check for class attribute' );
21 equals( jQuery('#name').attr('name'), "name", 'Check for name attribute' );
22 equals( jQuery('#text1').attr('name'), "action", 'Check for name attribute' );
23 ok( jQuery('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
24 // Temporarily disabled. See: #4299
25 // ok( jQuery('#form').attr('action','newformaction').attr('action').indexOf("newformaction") >= 0, 'Check that action attribute was changed' );
26 equals( jQuery('#text1').attr('maxlength'), '30', 'Check for maxlength attribute' );
27 equals( jQuery('#text1').attr('maxLength'), '30', 'Check for maxLength attribute' );
28 equals( jQuery('#area1').attr('maxLength'), '30', 'Check for maxLength attribute' );
29 equals( jQuery('#select2').attr('selectedIndex'), 3, 'Check for selectedIndex attribute' );
30 equals( jQuery('#foo').attr('nodeName').toUpperCase(), 'DIV', 'Check for nodeName attribute' );
31 equals( jQuery('#foo').attr('tagName').toUpperCase(), 'DIV', 'Check for tagName attribute' );
33 // using innerHTML in IE causes href attribute to be serialized to the full path
34 jQuery('<a/>').attr({ 'id': 'tAnchor5', 'href': '#5' }).appendTo('#main');
35 equals( jQuery('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' );
37 equals( jQuery("<option/>").attr("selected"), false, "Check selected attribute on disconnected element." );
40 // Related to [5574] and [5683]
41 var body = document.body, $body = jQuery(body);
43 ok( $body.attr('foo') === undefined, 'Make sure that a non existent attribute returns undefined' );
44 ok( $body.attr('nextSibling') === null, 'Make sure a null expando returns null' );
46 body.setAttribute('foo', 'baz');
47 equals( $body.attr('foo'), 'baz', 'Make sure the dom attribute is retrieved when no expando is found' );
50 equals( $body.attr('foo'), 'bar', 'Make sure the expando is preferred over the dom attribute' );
52 $body.attr('foo','cool');
53 equals( $body.attr('foo'), 'cool', 'Make sure that setting works well when both expando and dom attribute are available' );
56 ok( $body.attr('foo') === undefined, 'Make sure the expando is preferred over the dom attribute, even if undefined' );
58 body.removeAttribute('foo'); // Cleanup
60 var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option");
61 optgroup.appendChild( option );
62 select.appendChild( optgroup );
64 equals( jQuery(option).attr("selected"), true, "Make sure that a single option is selected, even when in an optgroup." );
66 ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
67 ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
71 test("attr(String) in XML Files", function() {
74 jQuery.get("data/dashboard.xml", function(xml) {
75 equals( jQuery("locations", xml).attr("class"), "foo", "Check class attribute in XML document" );
76 equals( jQuery("location", xml).attr("for"), "bar", "Check for attribute in XML document" );
82 test("attr(String, Function)", function() {
84 equals( jQuery('#text1').attr('value', function() { return this.id ;})[0].value, "text1", "Set value from id" );
85 equals( jQuery('#text1').attr('title', function(i) { return i }).attr('title'), "0", "Set value with an index");
88 test("attr(Hash)", function() {
91 jQuery("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
92 if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
94 ok( pass, "Set Multiple Attributes" );
95 equals( jQuery('#text1').attr({'value': function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" );
96 equals( jQuery('#text1').attr({'title': function(i) { return i; }}).attr('title'), "0", "Set attribute to computed value #2");
100 test("attr(String, Object)", function() {
102 var div = jQuery("div").attr("foo", "bar"),
104 for ( var i = 0; i < div.size(); i++ ) {
105 if ( div.get(i).getAttribute('foo') != "bar" ){
110 equals( fail, false, "Set Attribute, the #"+fail+" element didn't get the attribute 'foo'" );
112 // Fails on IE since recent changes to .attr()
113 // ok( jQuery("#foo").attr({"width": null}), "Try to set an attribute to nothing" );
115 jQuery("#name").attr('name', 'something');
116 equals( jQuery("#name").attr('name'), 'something', 'Set name attribute' );
117 jQuery("#check2").attr('checked', true);
118 equals( document.getElementById('check2').checked, true, 'Set checked attribute' );
119 jQuery("#check2").attr('checked', false);
120 equals( document.getElementById('check2').checked, false, 'Set checked attribute' );
121 jQuery("#text1").attr('readonly', true);
122 equals( document.getElementById('text1').readOnly, true, 'Set readonly attribute' );
123 jQuery("#text1").attr('readonly', false);
124 equals( document.getElementById('text1').readOnly, false, 'Set readonly attribute' );
125 jQuery("#name").attr('maxlength', '5');
126 equals( document.getElementById('name').maxLength, '5', 'Set maxlength attribute' );
127 jQuery("#name").attr('maxLength', '10');
128 equals( document.getElementById('name').maxLength, '10', 'Set maxlength attribute' );
130 var table = jQuery('#table').append("<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>"),
131 td = table.find('td:first');
132 td.attr("rowspan", "2");
133 equals( td[0].rowSpan, 2, "Check rowspan is correctly set" );
134 td.attr("colspan", "2");
135 equals( td[0].colSpan, 2, "Check colspan is correctly set" );
136 table.attr("cellspacing", "2");
137 equals( table[0].cellSpacing, 2, "Check cellspacing is correctly set" );
140 jQuery("#name").attr('someAttr', '0');
141 equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' );
142 jQuery("#name").attr('someAttr', 0);
143 equals( jQuery("#name").attr('someAttr'), 0, 'Set attribute to the number 0' );
144 jQuery("#name").attr('someAttr', 1);
145 equals( jQuery("#name").attr('someAttr'), 1, 'Set attribute to the number 1' );
147 // using contents will get comments regular, text, and comment nodes
148 var j = jQuery("#nonnodes").contents();
150 j.attr("name", "attrvalue");
151 equals( j.attr("name"), "attrvalue", "Check node,textnode,comment for attr" );
152 j.removeAttr("name");
156 var type = jQuery("#check2").attr('type');
159 jQuery("#check2").attr('type','hidden');
163 ok( thrown, "Exception thrown when trying to change type property" );
164 equals( type, jQuery("#check2").attr('type'), "Verify that you can't change the type of an input element" );
166 var check = document.createElement("input");
169 jQuery(check).attr('type','checkbox');
173 ok( thrown, "Exception thrown when trying to change type property" );
174 equals( "checkbox", jQuery(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
176 var check = jQuery("<input />");
179 check.attr('type','checkbox');
183 ok( thrown, "Exception thrown when trying to change type property" );
184 equals( "checkbox", check.attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
186 var button = jQuery("#button");
189 button.attr('type','submit');
193 ok( thrown, "Exception thrown when trying to change type property" );
194 equals( "button", button.attr('type'), "Verify that you can't change the type of a button element" );
197 test("attr(jquery_method)", function(){
200 var $elem = jQuery("<div />"),
204 $elem.attr({'html': 'foo'}, true);
205 equals( elem.innerHTML, 'foo', 'attr(html)');
207 $elem.attr({'text': 'bar'}, true);
208 equals( elem.innerHTML, 'bar', 'attr(text)');
210 $elem.attr({'css': {color:'red'}}, true);
211 ok( /^(#ff0000|red)$/i.test(elem.style.color), 'attr(css)');
213 $elem.attr({'height': 10}, true);
214 equals( elem.style.height, '10px', 'attr(height)');
216 // Multiple attributes
220 css:{ paddingLeft:1, paddingRight:1 }
223 equals( elem.style.width, '10px', 'attr({...})');
224 equals( elem.style.paddingLeft, '1px', 'attr({...})');
225 equals( elem.style.paddingRight, '1px', 'attr({...})');
229 test("attr(String, Object) - Loaded via XML document", function() {
232 jQuery.get('data/dashboard.xml', function(xml) {
234 jQuery('tab', xml).each(function() {
235 titles.push(jQuery(this).attr('title'));
237 equals( titles[0], 'Location', 'attr() in XML context: Check first title' );
238 equals( titles[1], 'Users', 'attr() in XML context: Check second title' );
244 test("attr('tabindex')", function() {
247 // elements not natively tabbable
248 equals(jQuery('#listWithTabIndex').attr('tabindex'), 5, 'not natively tabbable, with tabindex set to 0');
249 equals(jQuery('#divWithNoTabIndex').attr('tabindex'), undefined, 'not natively tabbable, no tabindex set');
252 equals(jQuery('#linkWithNoTabIndex').attr('tabindex'), 0, 'anchor with href, no tabindex set');
253 equals(jQuery('#linkWithTabIndex').attr('tabindex'), 2, 'anchor with href, tabindex set to 2');
254 equals(jQuery('#linkWithNegativeTabIndex').attr('tabindex'), -1, 'anchor with href, tabindex set to -1');
256 // anchor without href
257 equals(jQuery('#linkWithNoHrefWithNoTabIndex').attr('tabindex'), undefined, 'anchor without href, no tabindex set');
258 equals(jQuery('#linkWithNoHrefWithTabIndex').attr('tabindex'), 1, 'anchor without href, tabindex set to 2');
259 equals(jQuery('#linkWithNoHrefWithNegativeTabIndex').attr('tabindex'), -1, 'anchor without href, no tabindex set');
262 test("attr('tabindex', value)", function() {
265 var element = jQuery('#divWithNoTabIndex');
266 equals(element.attr('tabindex'), undefined, 'start with no tabindex');
268 // set a positive string
269 element.attr('tabindex', '1');
270 equals(element.attr('tabindex'), 1, 'set tabindex to 1 (string)');
273 element.attr('tabindex', '0');
274 equals(element.attr('tabindex'), 0, 'set tabindex to 0 (string)');
276 // set a negative string
277 element.attr('tabindex', '-1');
278 equals(element.attr('tabindex'), -1, 'set tabindex to -1 (string)');
280 // set a positive number
281 element.attr('tabindex', 1);
282 equals(element.attr('tabindex'), 1, 'set tabindex to 1 (number)');
285 element.attr('tabindex', 0);
286 equals(element.attr('tabindex'), 0, 'set tabindex to 0 (number)');
288 // set a negative number
289 element.attr('tabindex', -1);
290 equals(element.attr('tabindex'), -1, 'set tabindex to -1 (number)');
292 element = jQuery('#linkWithTabIndex');
293 equals(element.attr('tabindex'), 2, 'start with tabindex 2');
295 element.attr('tabindex', -1);
296 equals(element.attr('tabindex'), -1, 'set negative tabindex');
299 test("removeAttr(String)", function() {
301 equals( jQuery('#mark').removeAttr( "class" )[0].className, "", "remove class" );
304 test("val()", function() {
307 document.getElementById('text1').value = "bla";
308 equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
312 equals( jQuery("#text1").val(), "Test", "Check for value of input element" );
313 // ticket #1714 this caused a JS error in IE
314 equals( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" );
315 ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );
317 equals( jQuery('#select2').val(), '3', 'Call val() on a single="single" select' );
319 same( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' );
321 equals( jQuery('#option3c').val(), '2', 'Call val() on a option element with value' );
323 equals( jQuery('#option3a').val(), '', 'Call val() on a option element with empty value' );
325 equals( jQuery('#option3e').val(), 'no value', 'Call val() on a option element with no value attribute' );
327 equals( jQuery('#option3a').val(), '', 'Call val() on a option element with no value attribute' );
329 jQuery('#select3').val("");
330 same( jQuery('#select3').val(), [''], 'Call val() on a multiple="multiple" select' );
332 var checks = jQuery("<input type='checkbox' name='test' value='1'/><input type='checkbox' name='test' value='2'/><input type='checkbox' name='test' value=''/><input type='checkbox' name='test'/>").appendTo("#form");
334 same( checks.serialize(), "", "Get unchecked values." );
336 equals( checks.eq(3).val(), "on", "Make sure a value of 'on' is provided if none is specified." );
339 same( checks.serialize(), "test=2", "Get a single checked value." );
341 checks.val([ "1", "" ]);
342 same( checks.serialize(), "test=1&test=", "Get multiple checked values." );
344 checks.val([ "", "2" ]);
345 same( checks.serialize(), "test=2&test=", "Get multiple checked values." );
347 checks.val([ "1", "on" ]);
348 same( checks.serialize(), "test=1&test=on", "Get multiple checked values." );
353 var testVal = function(valueObj) {
356 jQuery("#text1").val(valueObj( 'test' ));
357 equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" );
359 jQuery("#text1").val(valueObj( 67 ));
360 equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" );
362 jQuery("#select1").val(valueObj( "3" ));
363 equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
365 jQuery("#select1").val(valueObj( 2 ));
366 equals( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" );
368 jQuery("#select1").append("<option value='4'>four</option>");
369 jQuery("#select1").val(valueObj( 4 ));
370 equals( jQuery("#select1").val(), "4", "Should be possible to set the val() to a newly created option" );
372 // using contents will get comments regular, text, and comment nodes
373 var j = jQuery("#nonnodes").contents();
374 j.val(valueObj( "asdf" ));
375 equals( j.val(), "asdf", "Check node,textnode,comment with val()" );
376 j.removeAttr("value");
379 test("val(String/Number)", function() {
383 test("val(Function)", function() {
384 testVal(functionReturningObj);
387 test("val(Function) with incoming value", function() {
390 var oldVal = jQuery("#text1").val();
392 jQuery("#text1").val(function(i, val) {
393 equals( val, oldVal, "Make sure the incoming value is correct." );
397 equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" );
399 oldVal = jQuery("#text1").val();
401 jQuery("#text1").val(function(i, val) {
402 equals( val, oldVal, "Make sure the incoming value is correct." );
406 equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" );
408 oldVal = jQuery("#select1").val();
410 jQuery("#select1").val(function(i, val) {
411 equals( val, oldVal, "Make sure the incoming value is correct." );
415 equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
417 oldVal = jQuery("#select1").val();
419 jQuery("#select1").val(function(i, val) {
420 equals( val, oldVal, "Make sure the incoming value is correct." );
424 equals( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" );
426 jQuery("#select1").append("<option value='4'>four</option>");
428 oldVal = jQuery("#select1").val();
430 jQuery("#select1").val(function(i, val) {
431 equals( val, oldVal, "Make sure the incoming value is correct." );
435 equals( jQuery("#select1").val(), "4", "Should be possible to set the val() to a newly created option" );
438 var testAddClass = function(valueObj) {
440 var div = jQuery("div");
441 div.addClass( valueObj("test") );
443 for ( var i = 0; i < div.size(); i++ ) {
444 if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
446 ok( pass, "Add Class" );
448 // using contents will get regular, text, and comment nodes
449 var j = jQuery("#nonnodes").contents();
450 j.addClass( valueObj("asdf") );
451 ok( j.hasClass("asdf"), "Check node,textnode,comment for addClass" );
453 div = jQuery("<div/>");
455 div.addClass( valueObj("test") );
456 equals( div.attr("class"), "test", "Make sure there's no extra whitespace." );
458 div.attr("class", " foo");
459 div.addClass( valueObj("test") );
460 equals( div.attr("class"), "foo test", "Make sure there's no extra whitespace." );
462 div.attr("class", "foo");
463 div.addClass( valueObj("bar baz") );
464 equals( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." );
467 test("addClass(String)", function() {
468 testAddClass(bareObj);
471 test("addClass(Function)", function() {
472 testAddClass(functionReturningObj);
475 test("addClass(Function) with incoming value", function() {
478 var div = jQuery("div"), old = div.map(function(){
479 return jQuery(this).attr("class");
482 div.addClass(function(i, val) {
483 if ( this.id !== "_firebugConsole" ) {
484 equals( val, old[i], "Make sure the incoming value is correct." );
490 for ( var i = 0; i < div.size(); i++ ) {
491 if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
493 ok( pass, "Add Class" );
496 var testRemoveClass = function(valueObj) {
499 var $divs = jQuery('div');
501 $divs.addClass("test").removeClass( valueObj("test") );
503 ok( !$divs.is('.test'), "Remove Class" );
506 $divs = jQuery('div');
508 $divs.addClass("test").addClass("foo").addClass("bar");
509 $divs.removeClass( valueObj("test") ).removeClass( valueObj("bar") ).removeClass( valueObj("foo") );
511 ok( !$divs.is('.test,.bar,.foo'), "Remove multiple classes" );
514 $divs = jQuery('div');
516 // Make sure that a null value doesn't cause problems
517 $divs.eq(0).addClass("test").removeClass( valueObj(null) );
518 ok( $divs.eq(0).is('.test'), "Null value passed to removeClass" );
520 $divs.eq(0).addClass("test").removeClass( valueObj("") );
521 ok( $divs.eq(0).is('.test'), "Empty string passed to removeClass" );
523 // using contents will get regular, text, and comment nodes
524 var j = jQuery("#nonnodes").contents();
525 j.removeClass( valueObj("asdf") );
526 ok( !j.hasClass("asdf"), "Check node,textnode,comment for removeClass" );
528 var div = document.createElement("div");
529 div.className = " test foo ";
531 jQuery(div).removeClass( valueObj("foo") );
532 equals( div.className, "test", "Make sure remaining className is trimmed." );
534 div.className = " test ";
536 jQuery(div).removeClass( valueObj("test") );
537 equals( div.className, "", "Make sure there is nothing left after everything is removed." );
540 test("removeClass(String) - simple", function() {
541 testRemoveClass(bareObj);
544 test("removeClass(Function) - simple", function() {
545 testRemoveClass(functionReturningObj);
548 test("removeClass(Function) with incoming value", function() {
551 var $divs = jQuery('div').addClass("test"), old = $divs.map(function(){
552 return jQuery(this).attr("class");
555 $divs.removeClass(function(i, val) {
556 if ( this.id !== "_firebugConsole" ) {
557 equals( val, old[i], "Make sure the incoming value is correct." );
562 ok( !$divs.is('.test'), "Remove Class" );
567 var testToggleClass = function(valueObj) {
570 var e = jQuery("#firstp");
571 ok( !e.is(".test"), "Assert class not present" );
572 e.toggleClass( valueObj("test") );
573 ok( e.is(".test"), "Assert class present" );
574 e.toggleClass( valueObj("test") );
575 ok( !e.is(".test"), "Assert class not present" );
577 // class name with a boolean
578 e.toggleClass( valueObj("test"), false );
579 ok( !e.is(".test"), "Assert class not present" );
580 e.toggleClass( valueObj("test"), true );
581 ok( e.is(".test"), "Assert class present" );
582 e.toggleClass( valueObj("test"), false );
583 ok( !e.is(".test"), "Assert class not present" );
585 // multiple class names
586 e.addClass("testA testB");
587 ok( (e.is(".testA.testB")), "Assert 2 different classes present" );
588 e.toggleClass( valueObj("testB testC") );
589 ok( (e.is(".testA.testC") && !e.is(".testB")), "Assert 1 class added, 1 class removed, and 1 class kept" );
590 e.toggleClass( valueObj("testA testC") );
591 ok( (!e.is(".testA") && !e.is(".testB") && !e.is(".testC")), "Assert no class present" );
593 // toggleClass storage
595 ok( e.get(0).className === "", "Assert class is empty (data was empty)" );
596 e.addClass("testD testE");
597 ok( e.is(".testD.testE"), "Assert class present" );
599 ok( !e.is(".testD.testE"), "Assert class not present" );
600 ok( e.data('__className__') === 'testD testE', "Assert data was stored" );
602 ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
603 e.toggleClass(false);
604 ok( !e.is(".testD.testE"), "Assert class not present" );
606 ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
608 e.toggleClass(false);
610 ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
615 e.removeClass("testD");
616 e.removeData('__className__');
619 test("toggleClass(String|boolean|undefined[, boolean])", function() {
620 testToggleClass(bareObj);
623 test("toggleClass(Function[, boolean])", function() {
624 testToggleClass(functionReturningObj);
627 test("toggleClass(Fucntion[, boolean]) with incoming value", function() {
630 var e = jQuery("#firstp"), old = e.attr("class");
631 ok( !e.is(".test"), "Assert class not present" );
633 e.toggleClass(function(i, val) {
634 equals( val, old, "Make sure the incoming value is correct." );
637 ok( e.is(".test"), "Assert class present" );
639 old = e.attr("class");
641 e.toggleClass(function(i, val) {
642 equals( val, old, "Make sure the incoming value is correct." );
645 ok( !e.is(".test"), "Assert class not present" );
647 old = e.attr("class");
649 // class name with a boolean
650 e.toggleClass(function(i, val, state) {
651 equals( val, old, "Make sure the incoming value is correct." );
652 equals( state, false, "Make sure that the state is passed in." );
655 ok( !e.is(".test"), "Assert class not present" );
657 old = e.attr("class");
659 e.toggleClass(function(i, val, state) {
660 equals( val, old, "Make sure the incoming value is correct." );
661 equals( state, true, "Make sure that the state is passed in." );
664 ok( e.is(".test"), "Assert class present" );
666 old = e.attr("class");
668 e.toggleClass(function(i, val, state) {
669 equals( val, old, "Make sure the incoming value is correct." );
670 equals( state, false, "Make sure that the state is passed in." );
673 ok( !e.is(".test"), "Assert class not present" );
676 e.removeClass("test");
677 e.removeData('__className__');
680 test("addClass, removeClass, hasClass", function() {
683 var jq = jQuery("<p>Hi</p>"), x = jq[0];
686 equals( x.className, "hi", "Check single added class" );
688 jq.addClass("foo bar");
689 equals( x.className, "hi foo bar", "Check more added classes" );
692 equals( x.className, "", "Remove all classes" );
694 jq.addClass("hi foo bar");
695 jq.removeClass("foo");
696 equals( x.className, "hi bar", "Check removal of one class" );
698 ok( jq.hasClass("hi"), "Check has1" );
699 ok( jq.hasClass("bar"), "Check has2" );
701 var jq = jQuery("<p class='class1\nclass2\tcla.ss3\n'></p>");
702 ok( jq.hasClass("class1"), "Check hasClass with carriage return" );
703 ok( jq.is(".class1"), "Check is with carriage return" );
704 ok( jq.hasClass("class2"), "Check hasClass with tab" );
705 ok( jq.is(".class2"), "Check is with tab" );
706 ok( jq.hasClass("cla.ss3"), "Check hasClass with dot" );
708 jq.removeClass("class2");
709 ok( jq.hasClass("class2")==false, "Check the class has been properly removed" );
710 jq.removeClass("cla");
711 ok( jq.hasClass("cla.ss3"), "Check the dotted class has not been removed" );
712 jq.removeClass("cla.ss3");
713 ok( jq.hasClass("cla.ss3")==false, "Check the dotted class has been removed" );