arf how stupid of me, thanks for the head up, this works:

 function getStyle (selector){
  var re = new RegExp('(^|,)\\s*'+selector.toLowerCase()+'\\s*(,|$)');
  var style = "";
  $.each ($.makeArray(document.styleSheets), function(){
    $.each (this.cssRules || this.rules, function(){
       if (re.test(this.selectorText)) style += this.style.cssText + ';';
       });
   });
   return style;
}


var temp = getStyle('#myitem:hover');
alert("css= "+temp);

live here: http://jsbin.com/itipo


still, that's a heavy work around for something that i assumed would
be stored in memory. If i understand correctly you parse through each
css file, right?

On Thu, Mar 26, 2009 at 2:19 PM, Gilles <gil...@netxtra.net> wrote:
>
> Try changing to JQuery.each() instead (or $.each, but I believe it's
> JQuery.each()) in this case
>
> On Mar 26, 1:12 pm, Alexandre Plennevaux <aplennev...@gmail.com>
> wrote:
>> tried it but it returns an error, about the "each()"
>>
>> see & tweak :http://jsbin.com/avoxu
>>
>> On Thu, Mar 26, 2009 at 2:00 PM, Danny <d.wac...@prodigy.net> wrote:
>>
>> > What I've used to grab styles from the stylesheets (though never for
>> > pseudo classes; please try it!) is:
>> >        function getStyle (selector){
>> >          var re = new RegExp('(^|,)\\s*'+selector.toLowerCase()+'\\s*(,|
>> > $)');
>> >          var style = "";
>> >                each ($.makeArray(document.styleSheets), function(){
>> >                        each (this.cssRules || this.rules, function(){
>> >                                if (re.test(this.selectorText)) style += 
>> > this.style.cssText + ';';
>> >                        });
>> >                });
>> >          return style;
>> >        }
>>
>> > and use getStyle('a:hover')
>>
>> > This is simplified; it doesn't handle @import and @media or escape
>> > special characters, but it ought to work.
>>
>> > Danny
>>
>> > On Mar 26, 6:22 am, Alexandre Plennevaux <aplennev...@gmail.com>
>> > wrote:
>> >> i'm just trying to be as semantically correct as possible.
>>
>> >> say i want links to change their background color when the mouse passes 
>> >> over.
>> >> I can do it in css easily
>>
>> >> a {
>> >> background-color:red;
>>
>> >> }
>>
>> >> a:hover{
>> >> background-color:green;
>>
>> >> }
>>
>> >> now, for those who have javascript,  i want the color change to be an
>> >> animated color blend, from red to green.
>> >> I can of course retrieve the target color (green in this example) by
>> >> storing it via metadata, a custom attribute or the data attribute.
>> >> However, strictly speaking, its correct place is the css file itself,
>> >> where all styling should be.
>>
>> >> that's why i wanted to know if i can have access to the css properties
>> >> set in the stylesheet for the :hover pseudo class.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to