1 test("css(String|Hash)", function() {
4 equals( jQuery('#main').css("display"), 'none', 'Check for css property "display"');
6 ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible');
7 jQuery('#nothiddendiv').css({display: 'none'});
8 ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden');
9 jQuery('#nothiddendiv').css({display: 'block'});
10 ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible');
12 jQuery('#floatTest').css({styleFloat: 'right'});
13 equals( jQuery('#floatTest').css('styleFloat'), 'right', 'Modified CSS float using "styleFloat": Assert float is right');
14 jQuery('#floatTest').css({cssFloat: 'left'});
15 equals( jQuery('#floatTest').css('cssFloat'), 'left', 'Modified CSS float using "cssFloat": Assert float is left');
16 jQuery('#floatTest').css({'float': 'right'});
17 equals( jQuery('#floatTest').css('float'), 'right', 'Modified CSS float using "float": Assert float is right');
18 jQuery('#floatTest').css({'font-size': '30px'});
19 equals( jQuery('#floatTest').css('font-size'), '30px', 'Modified CSS font-size: Assert font-size is 30px');
21 jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
22 jQuery('#foo').css({opacity: n});
23 equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
24 jQuery('#foo').css({opacity: parseFloat(n)});
25 equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
27 jQuery('#foo').css({opacity: ''});
28 equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );
31 test("css(String, Object)", function() {
33 ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible');
34 jQuery('#nothiddendiv').css("display", 'none');
35 ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden');
36 jQuery('#nothiddendiv').css("display", 'block');
37 ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible');
39 jQuery('#floatTest').css('styleFloat', 'left');
40 equals( jQuery('#floatTest').css('styleFloat'), 'left', 'Modified CSS float using "styleFloat": Assert float is left');
41 jQuery('#floatTest').css('cssFloat', 'right');
42 equals( jQuery('#floatTest').css('cssFloat'), 'right', 'Modified CSS float using "cssFloat": Assert float is right');
43 jQuery('#floatTest').css('float', 'left');
44 equals( jQuery('#floatTest').css('float'), 'left', 'Modified CSS float using "float": Assert float is left');
45 jQuery('#floatTest').css('font-size', '20px');
46 equals( jQuery('#floatTest').css('font-size'), '20px', 'Modified CSS font-size: Assert font-size is 20px');
48 jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
49 jQuery('#foo').css('opacity', n);
50 equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
51 jQuery('#foo').css('opacity', parseFloat(n));
52 equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
54 jQuery('#foo').css('opacity', '');
55 equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );
56 // for #1438, IE throws JS error when filter exists but doesn't have opacity in it
57 if (jQuery.browser.msie) {
58 jQuery('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');");
60 equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when a different filter is set in IE, #1438" );
62 // using contents will get comments regular, text, and comment nodes
63 var j = jQuery("#nonnodes").contents();
64 j.css("padding-left", "1px");
65 equals( j.css("padding-left"), "1px", "Check node,textnode,comment css works" );
67 // opera sometimes doesn't update 'display' correctly, see #2037
68 jQuery("#t2037")[0].innerHTML = jQuery("#t2037")[0].innerHTML
69 equals( jQuery("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" );
72 test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function () {
75 var $checkedtest = jQuery("#checkedtest");
76 // IE6 was clearing "checked" in jQuery.css(elem, "height");
77 jQuery.css($checkedtest[0], "height");
78 ok( !! jQuery(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked." );
79 ok( ! jQuery(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked." );
80 ok( !! jQuery(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked." );
81 ok( ! jQuery(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked." );