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. On Thu, Mar 26, 2009 at 11:55 AM, DBJDBJ <dbj...@gmail.com> wrote: > > CSS properties, classes and/or pseudo clases are not "available" to > javascript. > They are availabel to DOM which is available to javascript. > "onmousover" event is triggered when mouse pointer starts "hovering" > over an element. > This means that this event is in a "hovered state". I do not > understand why are you trying > and what (sorry ;) but I can imagine code like this : > > element.onmouseover = function ( event ) > { > try { > element.hovered = "true" ; > } finally { > element.hovered = "false" ; > } > } > > quick and dirty, though ... > > On Mar 26, 10:11 am, Alexandre Plennevaux <aplennev...@gmail.com> > wrote: >> thanks all for your replies. I couldn't make it work. In fact i wonder >> if the css property for :hover is available for javascript at all, if >> the :hover state is not triggered. Would there be a workaround? >> >> On Wed, Mar 25, 2009 at 5:36 PM, DBJ <dbj...@gmail.com> wrote: >> >> > I would also suggest looking into this page: >> >> >http://james.padolsey.com/javascript/extending-jquerys-selector-capab... >> >> > and this plugin >> >> >http://plugins.jquery.com/project/EnhancedAttributeSelectors >> >> > although it (still) does not do exactly what you want ... >> >> > Regards >> >> > 2009/3/25 Richard D. Worth <rdwo...@gmail.com>: >> >> You may want to look at this plugin by Ariel Flesler for accessing css >> >> rules: >> >> >>http://plugins.jquery.com/project/Rule >> >> >>http://flesler.blogspot.com/2007/11/jqueryrule.html >> >> >> - Richard >> >> >> On Wed, Mar 25, 2009 at 2:42 AM, Alexandre Plennevaux >> >> <aplennev...@gmail.com> wrote: >> >> >>> hello! >> >> >>> i first posted this in the mailing list but no replies tells me my answer >> >>> is no, so this becomes a "feature request" >> >> >>> imagine i style the :hover pseudo-class of an element via css: >> >> >>> .myitem{ >> >>> background-color:green; >> >>> } >> >>> .myitem:hover{ >> >>> background-color:red >> >>> } >> >> >>> Is it possible to retrieve the background-color property of the >> >>> elemnent's :hover class via jquery? >> >> >>> i tried the obvious :http://jsbin.com/idudi/edit >> >> >>> $(function(){ >> >>> var temp = $('#myitem:hover').css(' >> >>> background-color'); >> >>> alert("color is "+temp); >> >> >>> }); >> >> >>> But that didn't work. It returns the default state. >> >> >>> the reason i'm asking this feature, is because semantically/structurally, >> >>> the best place to store a css property is obviously in the CSS, not in >> >>> some >> >>> sort of metadata. >> >>> It occurred me while doing an interaction prototype for my school website >> >>> :http://pixeline.be/test/heaj/colormap/colorfade.html >> >>> each link has its background color fade to a custom color. I could only >> >>> store it as metadata or custom attribute, i wish i could have just >> >>> retrieved >> >>> it from the css. >> >> >>> thank you for listening ! >> >> >>> Alexandre >> >> > -- >> > Dusan Jovanovic >> >http://dbj.org >> > ------------------------- >> > "html e-mail is expensive" ™ >> >> > This email originates from Dusan B. Jovanovic. It, and any >> > attachments, may contain confidential information and may be subject >> > to copyright or other intellectual property rights. It is only for the >> > use of the addressee(s). You may not copy, forward, disclose, save or >> > otherwise use it in any way if you are not the addressee(s) or >> > responsible for delivery. If you receive this email by mistake, please >> > advise the sender and cancel it immediately. Dusan B. Jovanovic may >> > monitor the content of emails within its network to ensure compliance >> > with its policies and procedures. Any email is susceptible to >> > alteration and its integrity cannot be assured. Dusan B. Jovanovic >> > shall not be liable if the message is altered, modified, falsified, or >> > edited. > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---