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