Hi,

> It would be nice if there was a JQuery Plugin for handling Styles. I found
> a script that is made to change styles (such as to stylesheets).
>
> Here it is:http://developer.apple.com/internet/webcontent/styles.html
>
> Hopefully someone will be able to turn it into a JQuery Plugin

It would be nice if that technique could be used to speed up .css(), but that 
won't work with jQuery in all cases. I thought about storing the CSS-Query of 
the $()-call and reuse it, but it doesn't work with XPath-Queries and it 
doesn't work with contexts:

var i = 0;
$('.blabla').each(function(){
        i+=32;
        $('.laber',this).css({'backgroundColor':'rgb('+i+','+i+','+i+')'});
});

There are also differences between jQuery CSS like selectors and CSS selectors 
(e.g. @ before attribute names) and not all Browsers support all 
CSS-Selectors supported by jQuery.

I also thought if it could be possible to only use that technique where it is 
possible, but finding that out might even take more time than just leaving it 
as is. There is also a problem, that element speciffic Styles always override 
the global styles:

<ul class="blabla">
        <li class="laber">asdf</li>
        <li class="laber">asdf</li>
        <li class="laber backe">asdf</li>
        <li class="laber">asdf</li>
        <li class="laber">asdf</li>
        <li class="laber">asdf</li>
        <li class="laber">asdf</li>
</ul>

var i = 0;
$('.blabla').each(function(){
        i+=32;
        $('.laber',this).css({'backgroundColor':'rgb('+i+','+i+','+i+')'});
});
$('.backe').css({'backgroundColor':'#fffff'});

You would expect the third Element to have white background now - me to, but 
the last call to .css() is the only one that can be optimized by adding a 
rule to the global stylesheet. That rule won't be applied, because the 
element speciffic stylesheet set in the each()-loop overrides it and the 
elements background stays grey.

So it is a nice idea, but won't work with jQuery.

Christof

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to