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

  • SEARCH
  • Home
  • 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 6027695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:37:49+00:00 2026-05-23T04:37:49+00:00

I have a jQuery UI Button that I am trying to style using CSS.

  • 0

I have a jQuery UI Button that I am trying to style using CSS. Basically all I want is a dark-green background, and a light-green hover color. I noticed that for whatever reason, specifying the desired styles in my CSS file didn’t work, so I added some code to apply them programmatically when the button is created:

//initialize the jQuery button with the correct styles
$( "button", ".buttonContainer" ).button();

//add a class that we can apply our styles to (jQuery likes to override styles applied to .ui-button)
$(".buttonContainer .ui-button").addClass("greenButton");

//override button styles (doesn't work when done through stylesheet)
$(".greenButton").css("background", "none !important");
$(".greenButton").css("background-color", "#006600 !important");
$(".greenButton").css("border", "1px solid darkGray !important");

//mouseover handler to change the background color (same reason as above)
$(".greenButton").hover(function() {
    //mouse-over handler
    $(this).css("background-color", "green !important");
}, function() {
    //mouse-out handler
    $(this).css("background-color", "#006600 !important");
});

This works fine in Chrome, IE, and Safari, but for some reason Firefox continues showing the default gray button styles (no scripting errors are reported). Interestingly, if I open the web-developer CSS editor, the button gets the correct styles instantly. I have the following in my CSS from back before I realized that the styles would only take if applied programmatically:

.greenButton {
    background-color: #006600 ! important;
}
.greenButton:hover {
    background-color: green ! important;
}

Anyways, what I see in Firefox by default looks like this:

Incorrect gray button

…when it should look like this (as seen in any other browser):

Correct button

Any ideas?

  • 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-05-23T04:37:49+00:00Added an answer on May 23, 2026 at 4:37 am

    In your CSS you are only setting the background-color attribute, while jQuery UI buttons are built with background image, which covers the color. You were correct to set ‘background:none’ via JS, but adding it to the element’s style multiple times via css() messes things up a bit – just inspect the style attribute of your button when active in, e.g. FireBug. It might well be that you hit a minor bug in FireFox. It works for me. In any case, here is working jsFiddle

    CSS:

    .greenButton {
      background: #006600 none ! important;
    }
    .greenButtonHover {
      background: #009900 none ! important;
    }
    

    HTML:

    <button>Should be green on hover</button>
    

    JS:

    $("button").button();
    $("button").addClass("greenButton");
    $(".greenButton").hover(function() {
        $(this).addClass('greenButtonHover');
    }, function() {       
        $(this).removeClass('greenButtonHover');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sing django and jQuery I am trying to implement a button that, using the
I have some jQuery/JavaScript code that I want to run only when there is
I have a jQuery datepicker that I want to restrict non work days -
Using a jQuery effect, I have a layer that has a collection of HTML
Trying to clean up some code. I have a button that has the following
I have some jQuery code. I have called an Ajax function file, file.php, that
I have this jQuery code that queries an API on a keyup event (via
Here's my setup. I'm using .NET: I have a Main.aspx lets call it. That
i am creating the textboxes dynamically using jquery on a button click. <table width=100%
I am currently working on rails3 application that uses jQuery. I have a javascript

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.