Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8541845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:55:23+00:00 2026-06-11T11:55:23+00:00

I have a class setup in my style sheet for the UI, and a

  • 0

I have a class setup in my style sheet for the UI, and a preferences section where the user can use a color-picker to style the page. The values are stored in the db as hex, but when I use those values to update the page via jQuery:

$nav.css("background-color", button_bg_color)

I lose the NEW :hover colors. The non-hover colors change correctly, but I see they get converted to RGB format, and I’m guessing that this is causing the issues with the :hover values.
I figure I can change my code and have the class change on hover to get around this, but is there a way to get jQuery to set the colors using the hex values? Or is there something else I’m missing?

UPDATE:
James Montagne is right in that you can’t change the :hover effect, so I changed it to a class. Now, using the hover() function, I’m still missing something:
Fiddle: http://jsfiddle.net/Y9EBt/6/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:55:24+00:00Added an answer on June 11, 2026 at 11:55 am

    There’s a problem here, “Javascript doesn’t support getting or setting the attributes of pseudo selectors, meaning that you cannot get the :hover css style directly.” [source]

    JQuery, does however have a .hover() function which could probably be used to change the hover item’s css indirectly. Example: jQuery CSS Hover

    Edit:
    Here is a fiddle where I show it working:
    http://jsfiddle.net/TvfB9/1/

    The key points are:

    • I created a global variable in the javascript (outside of the document ready function):
      hover_color = "#00FFff"; for storing the user’s “new” or “desired” hover color. Ideally, you’d probably want to initialize this to whatever is in the stylesheet on page load.

    • Then inside the change color function, I update the global variable: hover_color = hover_text_color;. In this example I’m assigning it the variable you were already using in your fiddle, but hover_text_color should be replaced with whatever value the user picks from your picker controls.

    • I added a hover function to the document ready javascript object, and set the CSS for the .nav class from the global variable.

        $('.nav').hover(function() {
            $(this).css('color', hover_color ); 
        },
        function() {
            $(this).css('color', '#ffffff');
        }); 

    Basically, when you set the CSS with .CSS it actually applies the CSS to the "style" attribute of the particular tags that have that class attached, it doesn't modify the CSS file in memory or anything. So by the time you run the hover function, it's pretty much forgotten about the changes you tried to make to your CSS class.

    For the sake of laziness I only make the foreground color change, and left the non-hover foreground color hardcoded, obviously, you won't want to 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have the following has_one setup: class Account has_one :user How can I
I have a page that is setup like this public partial class _Default :
If I have a simple class setup like this: class MyClass { private string
i have the following models setup class Player(models.Model): #slug = models.slugField(max_length=200) Player_Name = models.CharField(max_length=100)
I have this setup in my models: class Author(models.Model): name = models.CharField(max_length=100) class Topic(models.Model):
I have following models setup in my Django application class School(models.Model): name = models.TextField()
I have the following setup. Class, say, Car that has a CarPart (belongsTo=[car:Car]). When
I have a basic invoice setup with models: Invoice, Item, LineItems. # invoice.rb class
Hi everyone and couchdb pros, I have a mapping setup like such: class Product(BaseModel):
In C#, I have a class set up like so: class Page { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.