Side navigation
#5533 closed bug (invalid)
Opened November 18, 2009 11:55PM UTC
Closed June 13, 2010 06:39PM UTC
css(name) method does not work at IE, css( name, value ) work both IE and FF
Reported by: | ig4 | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.4 |
Component: | attributes | Version: | 1.3.2 |
Keywords: | CSS method | Cc: | |
Blocked by: | Blocking: |
Description
I met a issue, I need to setup multi <div> class using jQuery Css.
$("div.ucLabelHeader").css(cssLabelHeader); at IE only change first div.
only using .each() method + css( name, value ) work both FF and IE
code shown as below:
<script type="text/javascript"
src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
You may specify partial version numbers, such as "1" or "1.3",
with the same result. Doing so will automatically load the
latest version matching that partial revision pattern
(i.e. both 1 and 1.3 would load 1.3.2 today).
google.load("jquery", "1.3.2");
google.setOnLoadCallback(function() {
// Place init code here instead of $(document).ready()
});
</script>
<script type="text/javascript">
$("document").ready(function() {
var cssObj =
{
'width': '500px',
'height': '460px'
}
var cssLabelHeader =
{
'position': 'static',
'margin': '0px',
/*'padding': '3px 0pt 3px 0px',*/
'padding': '3px 0px 3px 0px',
'width': '460px',
'left': ' '
}
if (!$.browser.msie)
{
$("div#ealertScroll").css(cssObj);
$("div.ucLabelHeader").each(function(i) {
alert(i);
$(this).css(cssLabelHeader); ONLY WORK AT FF
$(this).css('position' , 'static'); Both IE and FF
});
}
});
</script>
<div id="ealertScroll" >
<div class="ucLabelHeader" style="margin: 0px; padding: 3px 0pt 3px 0px; width: 100%; text-indent: 8px;">1</div>
<div class="ucLabelHeader" style="margin: 0px; padding: 3px 0pt 3px 0px; width: 100%; text-indent: 8px;">2</div>
<div class="ucLabelHeader" style="margin: 0px; padding: 3px 0pt 3px 0px; width: 100%; text-indent: 8px;">3</div>
<div class="ucLabelHeader" style="margin: 0px; padding: 3px 0pt 3px 0px; width: 100%; text-indent: 8px;">4</div>
</div>
Actually, this is the IE bug:
<div id="a" style="background:red; position:absolute; height:100px; width:100px;"></div>
<script>
document.getElementById("a").style.left= " ";
document.getElementById("a").style.backgrounnd="gold";
</script>
the div"#a" 's background won't be gold;
Because the "left" attribute value can't be illegal characters such as " "or "10pm",
IE will return an "Error" object, and stop running the following script.
Just set it to "10px" or"";