attr: function(elem, name, value){
var fix = {
"for": "htmlFor",
"class": "className",
"float": "cssFloat",
innerHTML: "innerHTML",
className: "className",
value: "value",
disabled: "disabled"
};
var v;
if ( fix[name] ) {
if ( value != undefined ) elem[fix[name]] = value;
return elem[fix[name]];
} else if ( elem.getAttribute ) {
//add opacity process
if (name == 'opacity' && jQuery.browser.msie)
if (value != undefined){
name = 'filter';
value = 'alpha(opacity=' + value * 100 + ')';
}
if ( value != undefined ) elem.setAttribute( name, value );
v = elem.getAttribute( name, 2 );
if (name == 'opacity' && jQuery.browser.msie){
v = elem['filter'];
if (v){
v = parseFloat(v.match(/\d+/)[0])/100;
}
else
v = 0;
}
return v;
} else {
name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
//add opacity process
if (name == 'opacity' && jQuery.browser.msie)
if (value != undefined){
name = 'filter';
value = 'alpha(opacity=' + value * 100 + ')';
}
if ( value != undefined ) elem[name] = value;
v = elem[name];
if (name == 'opacity' && jQuery.browser.msie ){
v = elem['filter'];
if (v){
v = parseFloat(v.match(/\d+/)[0])/100;
}
else
v = 0;
}
return v;
}
},
You'll find the code is kinda ugly, but I'm not very clear the mechanism of jQuery. I see that as I calling:
$().css('opacity', 0)
it will call $.fn.css() -> $.fn.attr() -> jQuery.attr() with this.style, so in jQuery.attr() it can not judge if it's style object or an element, I think it's not very clear. And in jQuery.attr(), I thought only add some code arround ( blue color)
if ( value != undefined ) elem[name] = value;
that's enough. But I was wrong. Because for style object, the judgement "if ( elem.getAttribute )" will be successful. So I also add some code(red color) arround it. And this time as I test css('opacity', 1) in IE, it's ok. But I found as I call $().css('opacity') the result would be undefined, so there is also another bugs I think. And I found later in curCSS function, I add below code in the end of the function:
if ( prop == "opacity" && jQuery.browser.msie ){
ret = parseFloat( elem.style["filter"].match(/\d+/) )/100;
}
and seems that the jQuery.css not be used in $().css().
I don't know if this has some useful.
--
I like python!
My Blog: http://www.donews.net/limodou
UliPad Site: http://wiki.woodpecker.org.cn/moin/UliPad
UliPad Maillist: http://groups.google.com/group/ulipad
_______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
