Turn off the CSS hover effect for a custom button if the ng disabled attribute is set to true

My goal is to disable custom buttons, and the disable(pointer) function is working correctly.

The issue arises when we try to hover on the button, as the hover effect still works. I therefore need to disable hover as well.

I am looking to apply ng-disable for multiple custom buttons, without having to override the CSS for every single one.

Check out this jsFiddle for more information.

Here is the code snippet:

<button class="bt1" ng-disabled="true">BUTTON</button>
<button class="bt2" ng-disabled="true">BUTTON</button>

.bt1 {
  background-color: #e38000;
  border: 0 none;
  border-radius: 15px;
  color: #ffffff;
  font-size: 14px;
  height: 30px;
  width: 135px;
}
.bt1:hover {
  background-color: #ffff00;
  color: #999;
}

.bt2 {
  background-color: #33b3e3;
  border: 0 none;
  border-radius: 15px;
  color: #ffffff;
  font-size: 14px;
  height: 30px;
  width: 135px;
}
.bt2:hover {
  background-color: #a2ddf4;
  color: #999;
}

Thank you for your assistance.

Answer №1

Instead of

.bt1:hover{
    background-color: #ffff00;
    color: #999;
}
.bt2:hover{
    background-color: #a2ddf4;
    color: #999;
}

Try using

.bt1:not([disabled]):hover{
    background-color: #ffff00;
    color: #999;
}
.bt2:not([disabled]):hover{
    background-color: #a2ddf4;
    color: #999;
}

View working example here

EDIT:

If you want to apply common CSS to ALL disabled buttons, you can simply add

button:disabled, button:disabled:hover{
    background-color:red;
}

and change the color "red" to your preferred choice.

See updated example here

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Triggering the onChangeMonthYear() event manually for jQuery datepicker

Currently, I am working with this function: $('#picker').datepicker({ // ... onSelect: function(currDate){ } }); I would like to manually trigger the onSelect() function, but using $('#picker').datepicker.onSelect(); does ...

Can you provide a list of factors that influence coverage? Additionally, is there a specific algorithm available for calculating

As part of my Angular project, I am currently focusing on writing unit test cases using the Jasmine Framework and Karma. To ensure thorough testing coverage, I am utilizing Coverage-html (Istanbul). When it comes to coverage, there are several important t ...

Looking for help combining HTML5 Canvas and JavaScript to showcase images. Can anyone lend a hand?

I am currently in the process of developing an Android game using HTML5 and Javascript. I have managed to make some progress, but I have encountered a problem that has left me puzzled. Initially, my JS file and Html file were functioning well together for ...

What is the process for creating the AngularJS documentation?

I find the documentation for AngularJS to be easily understandable - I wonder how it is created? If JSDoc is used, where can I find the style sheet? ...

Expanding the width of CSS dropdown menus according to their content

When attempting to create a dynamic dropdown menu, I encountered an issue where the values were skewed in Internet Explorer if they exceeded the width of the dropdown. To fix this problem, I added select:hover{width:auto;position:absolute}. However, now th ...

AngularJS is receiving an array of null inputs

I have a form where data from my DB is displayed through WebApi. One of the controls will contain an array of values. There is a scenario where the user can edit and save it using the PUT function. Controller : $scope.Put= function () { $scope.i ...

Convert HTML table data to JSON format and customize cell values

Hey there, I have a HTML table that looks like this: <table id="people" border="1"> <thead> <tr> <th>Name</th> <th>Places</th> <th>Grade</th> </tr> & ...

Ensuring the validity of an HTML form by including onClick functionalities for additional form elements

I am working on a form that I put together using various pieces of code that I found online. My knowledge of HTML and JavaScript is very basic. The form includes a button that, when clicked, will add another set of the same form fields. Initially, I added ...

Step-by-step guide to setting up Angular 2 with fullpage.js scrolloverflow

I am currently working on a project using Angular 2 that incorporates the fullpage.js port from https://github.com/meiblorn/ngx-fullpage. I am facing an issue with implementing scrolloverflow on a specific section and could use some guidance. I have alread ...

Engage in a Play app featuring AngularJS frontend navigation

Currently, I am using the Play Framework to develop a REST service and I would like the front end to be built with Angularjs in order to make rest calls. I have configured a route provider as follows: angular.module("getAbscencePlans", ["getAbscencePlans. ...

Converting a JSON array into easy-to-read data

I've been searching through this website for quite a while now, but I can't seem to figure out how to extract human-readable values from this JSON array. An alert displays the following: {"item1":"value1","item2":"value2","item3":"value3"} I w ...

Tips for transferring information to an input field's value

There's an input box with an empty value that needs to be filled with data. <input type="text" value="" class="box"> $('.skills-tags').on('click', function(){ var value = $(".skills-tags").val(); $('.label-pr ...

Issues arise when attempting to extract data from a data provider using JSON within the context of the Ionic framework

Hey there! I'm relatively new to the world of Angular and Ionic, and I've embarked on a project to create a pokedex app. My approach involves using a JSON file containing an array of "pocket monsters". However, my current challenge lies in extrac ...

How can you adjust the div orientation for small screens using Bootstrap?

I've been working with Bootstrap and I'm facing an issue with the orientation of a div on small screens. On medium screens, I have two columns set to 6, 6 which should stack on top of each other on smaller screens. Here's how I want it to lo ...

Please ensure there is space reserved for the header above the content

Currently, I am working on creating a webpage with a unique banner design. My goal is for the content to scroll from the bottom and remain fixed directly under the upper portion of the banner. Initially, my idea was to have the content box take up the siz ...

Vertical stacks of DIVs suddenly vanish

I am currently creating a map grid using HTML/CSS with the following layout: #map { position: absolute; top: 2vw; bottom: 2vw; left: 2vw; right: 2vw; overflow: visible; background : blue; } .map-row { width: 100%; ba ...

Dynamic Bootstrap Popover: Creating interactive popups by dynamically attaching events to buttons

I am looking to implement the Bootstrap Popover module to create a confirmation dialog for a delete action. When a <button> is clicked, instead of immediately executing a function, I want a popup to appear allowing the user to either confirm or dismi ...

The JavaScript function is not being activated by clicking on Selenium in Chrome

Take a look at the HTML snippet below: <table class="table-main "> <thead> <tbody> <!----> <tr class="" ng-if="mapCtrl.isAdded" style=""> <td/> <td> <td> <t ...

Layout your Angular components with a column design using Flex Layout

Is there a way to adjust the width of a child component in an fxLayout set to column? Take this example for reference: https://stackblitz.com/edit/angular-fxlayout-custom-breakpoints?file=app%2Ftest.component.ts In the provided example, there are three f ...

Issues with Angular JS service functionality

Currently, I am utilizing a service to retrieve data from the server by using the $http.get() method. Initially, I attempted to call the function in the service and then access its variable from the controller. However, this approach did not yield the expe ...