有没有任何getter jQuerys CSS翻译? [英] Are there any getter jQuerys CSS translation?
问题描述
jQuery的跨浏览器支持是惊人的。
但是我想知道以下脚本是否可以在任何浏览器中工作。
$(#block1 ).css('background','blue');
$(#block2)。css('backgroundColor','#0000ff');
$(#block3)。css('background-color','rgb(0,0,255)');
if($(#block1)。css('background-color')== $(#block2)。css('background-color')&&
$(#block1)。css('background-color')== $(#block3)css('background-color'))
{
alert color:'+ $(#block1)。css('background'));
}
你自己。
jQuery's cross browser support is amazing. However I was wondering whether the following script will work in any browser or not.
$("#block1").css('background','blue');
$("#block2").css('backgroundColor', '#0000ff');
$("#block3").css('background-color', 'rgb(0, 0, 255)');
if ( $("#block1").css('background-color') == $("#block2").css('background-color') &&
$("#block1").css('background-color') == $("#block3").css('background-color') )
{
alert ( 'same color : ' + $("#block1").css('background') );
}
As you see these 3 different setter methods do exactly the same thing. Changing the background color to blue.
It seems that there are translations for the setter method of the .css
method.
I was curios if there are any translations for the getter method as well.
for some reason it didn't work on my google-chrome(3.0.195.27 - windows) but worked on firefox. hope it helps.
edit: further testing revealed interesting results.
a) it seems that chrome converts the #0000ff to rgb(0,0,255) but the same does not apply to "blue"
b) firefox will display very diferent results depending on the property you are asking for. Specificaly for the background-color property it converts the colors to the format rgb(0,0,255)
just watch:
feel free to test it out yourself.
这篇关于有没有任何getter jQuerys CSS翻译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!