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 jQuery('<a id="tAnchor5"></a>').attr('href', '#5').appendTo('#main'); // using innerHTML in IE causes href attribute to be serialized to the full path
34 equals( jQuery('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' );
36 equals( jQuery("<option/>").attr("selected"), false, "Check selected attribute on disconnected element." );
39 // Related to [5574] and [5683]
40 var body = document.body, $body = jQuery(body);
42 ok( $body.attr('foo') === undefined, 'Make sure that a non existent attribute returns undefined' );
43 ok( $body.attr('nextSibling') === null, 'Make sure a null expando returns null' );
45 body.setAttribute('foo', 'baz');
46 equals( $body.attr('foo'), 'baz', 'Make sure the dom attribute is retrieved when no expando is found' );
49 equals( $body.attr('foo'), 'bar', 'Make sure the expando is preferred over the dom attribute' );
51 $body.attr('foo','cool');
52 equals( $body.attr('foo'), 'cool', 'Make sure that setting works well when both expando and dom attribute are available' );
55 ok( $body.attr('foo') === undefined, 'Make sure the expando is preferred over the dom attribute, even if undefined' );
57 body.removeAttribute('foo'); // Cleanup
59 var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option");
60 optgroup.appendChild( option );
61 select.appendChild( optgroup );
63 equals( jQuery(option).attr("selected"), true, "Make sure that a single option is selected, even when in an optgroup." );
65 ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
66 ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
70 test("attr(String) in XML Files", function() {
73 jQuery.get("data/dashboard.xml", function(xml) {
74 equals( jQuery("locations", xml).attr("class"), "foo", "Check class attribute in XML document" );
75 equals( jQuery("location", xml).attr("for"), "bar", "Check for attribute in XML document" );
81 test("attr(String, Function)", function() {
83 equals( jQuery('#text1').attr('value', function() { return this.id ;})[0].value, "text1", "Set value from id" );
84 equals( jQuery('#text1').attr('title', function(i) { return i }).attr('title'), "0", "Set value with an index");
87 test("attr(Hash)", function() {
90 jQuery("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
91 if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
93 ok( pass, "Set Multiple Attributes" );
94 equals( jQuery('#text1').attr({'value': function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" );
95 equals( jQuery('#text1').attr({'title': function(i) { return i; }}).attr('title'), "0", "Set attribute to computed value #2");
99 test("attr(String, Object)", function() {
101 var div = jQuery("div").attr("foo", "bar"),
103 for ( var i = 0; i < div.size(); i++ ) {
104 if ( div.get(i).getAttribute('foo') != "bar" ){
109 equals( fail, false, "Set Attribute, the #"+fail+" element didn't get the attribute 'foo'" );
111 // Fails on IE since recent changes to .attr()
112 // ok( jQuery("#foo").attr({"width": null}), "Try to set an attribute to nothing" );
114 jQuery("#name").attr('name', 'something');
115 equals( jQuery("#name").attr('name'), 'something', 'Set name attribute' );
116 jQuery("#check2").attr('checked', true);
117 equals( document.getElementById('check2').checked, true, 'Set checked attribute' );
118 jQuery("#check2").attr('checked', false);
119 equals( document.getElementById('check2').checked, false, 'Set checked attribute' );
120 jQuery("#text1").attr('readonly', true);
121 equals( document.getElementById('text1').readOnly, true, 'Set readonly attribute' );
122 jQuery("#text1").attr('readonly', false);
123 equals( document.getElementById('text1').readOnly, false, 'Set readonly attribute' );
124 jQuery("#name").attr('maxlength', '5');
125 equals( document.getElementById('name').maxLength, '5', 'Set maxlength attribute' );
126 jQuery("#name").attr('maxLength', '10');
127 equals( document.getElementById('name').maxLength, '10', 'Set maxlength attribute' );
129 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>"),
130 td = table.find('td:first');
131 td.attr("rowspan", "2");
132 equals( td[0].rowSpan, 2, "Check rowspan is correctly set" );
133 td.attr("colspan", "2");
134 equals( td[0].colSpan, 2, "Check colspan is correctly set" );
135 table.attr("cellspacing", "2");
136 equals( table[0].cellSpacing, 2, "Check cellspacing is correctly set" );
139 jQuery("#name").attr('someAttr', '0');
140 equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' );
141 jQuery("#name").attr('someAttr', 0);
142 equals( jQuery("#name").attr('someAttr'), 0, 'Set attribute to the number 0' );
143 jQuery("#name").attr('someAttr', 1);
144 equals( jQuery("#name").attr('someAttr'), 1, 'Set attribute to the number 1' );
146 // using contents will get comments regular, text, and comment nodes
147 var j = jQuery("#nonnodes").contents();
149 j.attr("name", "attrvalue");
150 equals( j.attr("name"), "attrvalue", "Check node,textnode,comment for attr" );
151 j.removeAttr("name");
155 var type = jQuery("#check2").attr('type');
158 jQuery("#check2").attr('type','hidden');
162 ok( thrown, "Exception thrown when trying to change type property" );
163 equals( type, jQuery("#check2").attr('type'), "Verify that you can't change the type of an input element" );
165 var check = document.createElement("input");
168 jQuery(check).attr('type','checkbox');
172 ok( thrown, "Exception thrown when trying to change type property" );
173 equals( "checkbox", jQuery(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
175 var check = jQuery("<input />");
178 check.attr('type','checkbox');
182 ok( thrown, "Exception thrown when trying to change type property" );
183 equals( "checkbox", check.attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
185 var button = jQuery("#button");
188 button.attr('type','submit');
192 ok( thrown, "Exception thrown when trying to change type property" );
193 equals( "button", button.attr('type'), "Verify that you can't change the type of a button element" );
196 test("attr(jquery_method)", function(){
199 var $elem = jQuery("<div />"),
203 $elem.attr({'html': 'foo'}, true);
204 equals( elem.innerHTML, 'foo', 'attr(html)');
206 $elem.attr({'text': 'bar'}, true);
207 equals( elem.innerHTML, 'bar', 'attr(text)');
209 $elem.attr({'css': {color:'red'}}, true);
210 ok( /^(#ff0000|red)$/i.test(elem.style.color), 'attr(css)');
212 $elem.attr({'height': 10}, true);
213 equals( elem.style.height, '10px', 'attr(height)');
215 // Multiple attributes
219 css:{ paddingLeft:1, paddingRight:1 }
222 equals( elem.style.width, '10px', 'attr({...})');
223 equals( elem.style.paddingLeft, '1px', 'attr({...})');
224 equals( elem.style.paddingRight, '1px', 'attr({...})');
228 test("attr(String, Object) - Loaded via XML document", function() {
231 jQuery.get('data/dashboard.xml', function(xml) {
233 jQuery('tab', xml).each(function() {
234 titles.push(jQuery(this).attr('title'));
236 equals( titles[0], 'Location', 'attr() in XML context: Check first title' );
237 equals( titles[1], 'Users', 'attr() in XML context: Check second title' );
243 test("attr('tabindex')", function() {
246 // elements not natively tabbable
247 equals(jQuery('#listWithTabIndex').attr('tabindex'), 5, 'not natively tabbable, with tabindex set to 0');
248 equals(jQuery('#divWithNoTabIndex').attr('tabindex'), undefined, 'not natively tabbable, no tabindex set');
251 equals(jQuery('#linkWithNoTabIndex').attr('tabindex'), 0, 'anchor with href, no tabindex set');
252 equals(jQuery('#linkWithTabIndex').attr('tabindex'), 2, 'anchor with href, tabindex set to 2');
253 equals(jQuery('#linkWithNegativeTabIndex').attr('tabindex'), -1, 'anchor with href, tabindex set to -1');
255 // anchor without href
256 equals(jQuery('#linkWithNoHrefWithNoTabIndex').attr('tabindex'), undefined, 'anchor without href, no tabindex set');
257 equals(jQuery('#linkWithNoHrefWithTabIndex').attr('tabindex'), 1, 'anchor without href, tabindex set to 2');
258 equals(jQuery('#linkWithNoHrefWithNegativeTabIndex').attr('tabindex'), -1, 'anchor without href, no tabindex set');
261 test("attr('tabindex', value)", function() {
264 var element = jQuery('#divWithNoTabIndex');
265 equals(element.attr('tabindex'), undefined, 'start with no tabindex');
267 // set a positive string
268 element.attr('tabindex', '1');
269 equals(element.attr('tabindex'), 1, 'set tabindex to 1 (string)');
272 element.attr('tabindex', '0');
273 equals(element.attr('tabindex'), 0, 'set tabindex to 0 (string)');
275 // set a negative string
276 element.attr('tabindex', '-1');
277 equals(element.attr('tabindex'), -1, 'set tabindex to -1 (string)');
279 // set a positive number
280 element.attr('tabindex', 1);
281 equals(element.attr('tabindex'), 1, 'set tabindex to 1 (number)');
284 element.attr('tabindex', 0);
285 equals(element.attr('tabindex'), 0, 'set tabindex to 0 (number)');
287 // set a negative number
288 element.attr('tabindex', -1);
289 equals(element.attr('tabindex'), -1, 'set tabindex to -1 (number)');
291 element = jQuery('#linkWithTabIndex');
292 equals(element.attr('tabindex'), 2, 'start with tabindex 2');
294 element.attr('tabindex', -1);
295 equals(element.attr('tabindex'), -1, 'set negative tabindex');
298 test("removeAttr(String)", function() {
300 equals( jQuery('#mark').removeAttr( "class" )[0].className, "", "remove class" );
303 test("val()", function() {
306 document.getElementById('text1').value = "bla";
307 equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
311 equals( jQuery("#text1").val(), "Test", "Check for value of input element" );
312 // ticket #1714 this caused a JS error in IE
313 equals( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" );
314 ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );
316 equals( jQuery('#select2').val(), '3', 'Call val() on a single="single" select' );
318 same( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' );
320 equals( jQuery('#option3c').val(), '2', 'Call val() on a option element with value' );
322 equals( jQuery('#option3a').val(), '', 'Call val() on a option element with empty value' );
324 equals( jQuery('#option3e').val(), 'no value', 'Call val() on a option element with no value attribute' );
326 equals( jQuery('#option3a').val(), '', 'Call val() on a option element with no value attribute' );
328 jQuery('#select3').val("");
329 same( jQuery('#select3').val(), [''], 'Call val() on a multiple="multiple" select' );
331 var checks = jQuery("<input type='checkbox' name='test' value='1'/>").appendTo("#form")
332 .add( jQuery("<input type='checkbox' name='test' value='2'/>").appendTo("#form") )
333 .add( jQuery("<input type='checkbox' name='test' value=''/>").appendTo("#form") )
334 .add( jQuery("<input type='checkbox' name='test'/>").appendTo("#form") );
336 same( checks.serialize(), "", "Get unchecked values." );
338 equals( checks.eq(3).val(), "on", "Make sure a value of 'on' is provided if none is specified." );
341 same( checks.serialize(), "test=2", "Get a single checked value." );
343 checks.val([ "1", "" ]);
344 same( checks.serialize(), "test=1&test=", "Get multiple checked values." );
346 checks.val([ "", "2" ]);
347 same( checks.serialize(), "test=2&test=", "Get multiple checked values." );
349 checks.val([ "1", "on" ]);
350 same( checks.serialize(), "test=1&test=on", "Get multiple checked values." );
355 var testVal = function(valueObj) {
358 jQuery("#text1").val(valueObj( 'test' ));
359 equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" );
361 jQuery("#text1").val(valueObj( 67 ));
362 equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" );
364 jQuery("#select1").val(valueObj( "3" ));
365 equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
367 jQuery("#select1").val(valueObj( 2 ));
368 equals( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" );
370 jQuery("#select1").append("<option value='4'>four</option>");
371 jQuery("#select1").val(valueObj( 4 ));
372 equals( jQuery("#select1").val(), "4", "Should be possible to set the val() to a newly created option" );
374 // using contents will get comments regular, text, and comment nodes
375 var j = jQuery("#nonnodes").contents();
376 j.val(valueObj( "asdf" ));
377 equals( j.val(), "asdf", "Check node,textnode,comment with val()" );
378 j.removeAttr("value");
381 test("val(String/Number)", function() {
385 test("val(Function)", function() {
386 testVal(functionReturningObj);
389 test("val(Function) with incoming value", function() {
392 var oldVal = jQuery("#text1").val();
394 jQuery("#text1").val(function(i, val) {
395 equals( val, oldVal, "Make sure the incoming value is correct." );
399 equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" );
401 oldVal = jQuery("#text1").val();
403 jQuery("#text1").val(function(i, val) {
404 equals( val, oldVal, "Make sure the incoming value is correct." );
408 equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" );
410 oldVal = jQuery("#select1").val();
412 jQuery("#select1").val(function(i, val) {
413 equals( val, oldVal, "Make sure the incoming value is correct." );
417 equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
419 oldVal = jQuery("#select1").val();
421 jQuery("#select1").val(function(i, val) {
422 equals( val, oldVal, "Make sure the incoming value is correct." );
426 equals( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" );
428 jQuery("#select1").append("<option value='4'>four</option>");
430 oldVal = jQuery("#select1").val();
432 jQuery("#select1").val(function(i, val) {
433 equals( val, oldVal, "Make sure the incoming value is correct." );
437 equals( jQuery("#select1").val(), "4", "Should be possible to set the val() to a newly created option" );
440 var testAddClass = function(valueObj) {
442 var div = jQuery("div");
443 div.addClass( valueObj("test") );
445 for ( var i = 0; i < div.size(); i++ ) {
446 if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
448 ok( pass, "Add Class" );
450 // using contents will get regular, text, and comment nodes
451 var j = jQuery("#nonnodes").contents();
452 j.addClass( valueObj("asdf") );
453 ok( j.hasClass("asdf"), "Check node,textnode,comment for addClass" );
455 div = jQuery("<div/>");
457 div.addClass( valueObj("test") );
458 equals( div.attr("class"), "test", "Make sure there's no extra whitespace." );
460 div.attr("class", " foo");
461 div.addClass( valueObj("test") );
462 equals( div.attr("class"), "foo test", "Make sure there's no extra whitespace." );
465 test("addClass(String)", function() {
466 testAddClass(bareObj);
469 test("addClass(Function)", function() {
470 testAddClass(functionReturningObj);
473 test("addClass(Function) with incoming value", function() {
476 var div = jQuery("div"), old = div.map(function(){
477 return jQuery(this).attr("class");
480 div.addClass(function(i, val) {
481 equals( val, old[i], "Make sure the incoming value is correct." );
486 for ( var i = 0; i < div.size(); i++ ) {
487 if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
489 ok( pass, "Add Class" );
492 var testRemoveClass = function(valueObj) {
495 var $divs = jQuery('div');
497 $divs.addClass("test").removeClass( valueObj("test") );
499 ok( !$divs.is('.test'), "Remove Class" );
502 $divs = jQuery('div');
504 $divs.addClass("test").addClass("foo").addClass("bar");
505 $divs.removeClass( valueObj("test") ).removeClass( valueObj("bar") ).removeClass( valueObj("foo") );
507 ok( !$divs.is('.test,.bar,.foo'), "Remove multiple classes" );
510 $divs = jQuery('div');
512 // Make sure that a null value doesn't cause problems
513 $divs.eq(0).addClass("test").removeClass( valueObj(null) );
514 ok( $divs.eq(0).is('.test'), "Null value passed to removeClass" );
516 $divs.eq(0).addClass("test").removeClass( valueObj("") );
517 ok( $divs.eq(0).is('.test'), "Empty string passed to removeClass" );
519 // using contents will get regular, text, and comment nodes
520 var j = jQuery("#nonnodes").contents();
521 j.removeClass( valueObj("asdf") );
522 ok( !j.hasClass("asdf"), "Check node,textnode,comment for removeClass" );
524 var div = document.createElement("div");
525 div.className = " test foo ";
527 jQuery(div).removeClass( valueObj("foo") );
528 equals( div.className, "test", "Make sure remaining className is trimmed." );
530 div.className = " test ";
532 jQuery(div).removeClass( valueObj("test") );
533 equals( div.className, "", "Make sure there is nothing left after everything is removed." );
536 test("removeClass(String) - simple", function() {
537 testRemoveClass(bareObj);
540 test("removeClass(Function) - simple", function() {
541 testRemoveClass(functionReturningObj);
544 test("removeClass(Function) with incoming value", function() {
547 var $divs = jQuery('div').addClass("test"), old = $divs.map(function(){
548 return jQuery(this).attr("class");
551 $divs.removeClass(function(i, val) {
552 equals( val, old[i], "Make sure the incoming value is correct." );
556 ok( !$divs.is('.test'), "Remove Class" );
561 var testToggleClass = function(valueObj) {
564 var e = jQuery("#firstp");
565 ok( !e.is(".test"), "Assert class not present" );
566 e.toggleClass( valueObj("test") );
567 ok( e.is(".test"), "Assert class present" );
568 e.toggleClass( valueObj("test") );
569 ok( !e.is(".test"), "Assert class not present" );
571 // class name with a boolean
572 e.toggleClass( valueObj("test"), false );
573 ok( !e.is(".test"), "Assert class not present" );
574 e.toggleClass( valueObj("test"), true );
575 ok( e.is(".test"), "Assert class present" );
576 e.toggleClass( valueObj("test"), false );
577 ok( !e.is(".test"), "Assert class not present" );
579 // multiple class names
580 e.addClass("testA testB");
581 ok( (e.is(".testA.testB")), "Assert 2 different classes present" );
582 e.toggleClass( valueObj("testB testC") );
583 ok( (e.is(".testA.testC") && !e.is(".testB")), "Assert 1 class added, 1 class removed, and 1 class kept" );
584 e.toggleClass( valueObj("testA testC") );
585 ok( (!e.is(".testA") && !e.is(".testB") && !e.is(".testC")), "Assert no class present" );
587 // toggleClass storage
589 ok( e.get(0).className === "", "Assert class is empty (data was empty)" );
590 e.addClass("testD testE");
591 ok( e.is(".testD.testE"), "Assert class present" );
593 ok( !e.is(".testD.testE"), "Assert class not present" );
594 ok( e.data('__className__') === 'testD testE', "Assert data was stored" );
596 ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
597 e.toggleClass(false);
598 ok( !e.is(".testD.testE"), "Assert class not present" );
600 ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
602 e.toggleClass(false);
604 ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
609 e.removeClass("testD");
610 e.removeData('__className__');
613 test("toggleClass(String|boolean|undefined[, boolean])", function() {
614 testToggleClass(bareObj);
617 test("toggleClass(Function[, boolean])", function() {
618 testToggleClass(functionReturningObj);
621 test("toggleClass(Fucntion[, boolean]) with incoming value", function() {
624 var e = jQuery("#firstp"), old = e.attr("class");
625 ok( !e.is(".test"), "Assert class not present" );
627 e.toggleClass(function(i, val) {
628 equals( val, old, "Make sure the incoming value is correct." );
631 ok( e.is(".test"), "Assert class present" );
633 old = e.attr("class");
635 e.toggleClass(function(i, val) {
636 equals( val, old, "Make sure the incoming value is correct." );
639 ok( !e.is(".test"), "Assert class not present" );
641 old = e.attr("class");
643 // class name with a boolean
644 e.toggleClass(function(i, val, state) {
645 equals( val, old, "Make sure the incoming value is correct." );
646 equals( state, false, "Make sure that the state is passed in." );
649 ok( !e.is(".test"), "Assert class not present" );
651 old = e.attr("class");
653 e.toggleClass(function(i, val, state) {
654 equals( val, old, "Make sure the incoming value is correct." );
655 equals( state, true, "Make sure that the state is passed in." );
658 ok( e.is(".test"), "Assert class present" );
660 old = e.attr("class");
662 e.toggleClass(function(i, val, state) {
663 equals( val, old, "Make sure the incoming value is correct." );
664 equals( state, false, "Make sure that the state is passed in." );
667 ok( !e.is(".test"), "Assert class not present" );
670 e.removeClass("test");
671 e.removeData('__className__');
674 test("addClass, removeClass, hasClass", function() {
677 var jq = jQuery("<p>Hi</p>"), x = jq[0];
680 equals( x.className, "hi", "Check single added class" );
682 jq.addClass("foo bar");
683 equals( x.className, "hi foo bar", "Check more added classes" );
686 equals( x.className, "", "Remove all classes" );
688 jq.addClass("hi foo bar");
689 jq.removeClass("foo");
690 equals( x.className, "hi bar", "Check removal of one class" );
692 ok( jq.hasClass("hi"), "Check has1" );
693 ok( jq.hasClass("bar"), "Check has2" );
695 var jq = jQuery("<p class='class1\nclass2\tcla.ss3\n'></p>");
696 ok( jq.hasClass("class1"), "Check hasClass with carriage return" );
697 ok( jq.is(".class1"), "Check is with carriage return" );
698 ok( jq.hasClass("class2"), "Check hasClass with tab" );
699 ok( jq.is(".class2"), "Check is with tab" );
700 ok( jq.hasClass("cla.ss3"), "Check hasClass with dot" );
702 jq.removeClass("class2");
703 ok( jq.hasClass("class2")==false, "Check the class has been properly removed" );
704 jq.removeClass("cla");
705 ok( jq.hasClass("cla.ss3"), "Check the dotted class has not been removed" );
706 jq.removeClass("cla.ss3");
707 ok( jq.hasClass("cla.ss3")==false, "Check the dotted class has been removed" );