Modify the color of the panel header when the button is clicked

I am trying to modify the background color of my panel header using a button that changes the color scheme of my site. The button currently functions on AFO. Below is the stylesheet for the button:

.AFO { background-color: #fff;}
.AFO h1 { color: #00159d; }
.AFO h2 { color: #00159d; }
.AFO h3 { color: #00159d; }
.AFO h4 { color: #00159d; }
.AFO h5 { color: #00159d; }
.AFO h6 { color: #00159d; }
.AFO p { color: #00159d; }
.AFO th { background-color: #c3cced; color: #00159d;}
.AFO panel-header { background-image:-webkit-linear-gradient(top, #c3cced, #00159d ) !important; color: #00159d !important;}

The HTML

<div class="panel-heading orange ct-orange" ng-class="colorScheme">Details</div>

Although I have the button working, I am unable to locate the JavaScript responsible for it. When inspecting the element, I noticed that AFO is persistently added to the class, maintaining its original orange color.

So far, the only way I have successfully changed the panel color is by modifying the top line in the CSS to this:

.AFO { background-color: #fff; background-image:-webkit-linear-gradient(top, #c3cced, #00159d ) !important; color: #00159d !important;}

I would appreciate any suggestions or ideas on how to achieve this. If you need more information, please let me know. I will continue my search for the button!!!

Update: Found the JavaScript!

    $(function() {
  $(".colorSelect").change(function() {
    $("body").attr('class', '');
    $(".colorSelect").each(function() {
      $("body").addClass($(this).val());
    });
  });
});

Answer №1

It appears you forgot to include the . when targeting the class element

Original Code

.AFO panel-header { background-image:-webkit-linear-gradient(top, #c3cced, #00159d ) !important; color: #00159d !important;}

Correction

The correct syntax should be .AFO .panel-header without a space, since AFO is being added to that element. Here is the updated code:

.AFO.panel-header { background-image:-webkit-linear-gradient(top, #c3cced, #00159d ) !important; color: #00159d !important;}

Correction

The class name should be panel-heading instead of panel-header

Therefore, your CSS code should be as follows:

.AFO.panel-heading { background-image:-webkit-linear-gradient(top, #c3cced, #00159d ) !important; color: #00159d !important;}

Check out the updated code on Fiddle

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

The fixed div is always positioned in the top corner

My webpage has a 'Book Now' button that remains at the top of the viewport with a 10px gap. However, due to the parent element having a height of 100%, the button scrolls out of view once the viewport surpasses that height. To see an example, cli ...

Transition animation using jQuery

I am seeking assistance with jQuery effects. Specifically, I have set images to a certain position using style, and I want users to be able to drag these images around once the HTML page is published. Is there a plugin or command in jQuery that will allow ...

JavaScript: Struggles with utilizing a function as an argument and later executing it inside a nested function

I've been struggling with defining a new function, and I need help resolving it. Here's an example that I was initially referencing: Pass arguments into ajax onreadystatechange callback? I wasn't able to find the solution through research, ...

How to insert a row above the header in an Excel sheet using JavaScript within

i am using excel js to export json data to excel. The json data is successfully exported to the sheet, but now I need to add a row that provides details of the sheet above the header text. for more details please refer image the code is shown below: i ...

How can I specify the array's length when using JSON.stringify in AngularJS?

I am looking to store form values in JSON to send via $http.post. One of the values, rooms, should be an array with a length determined by the selected value from md-select. The value of Adult should be included within each room entry. var data = { rooms: ...

jQuery.get() function is limited to specific types of webpages

I have successfully combined multiple weather APIs on my website, which can be found here. Recently, I started using the weather.gov API and it has been quite effective. However, there are certain data points that I need to extract which the weather.gov A ...

Cors issue resolved: No 'Access-Control-Allow-Origin' error

I am currently working on a function that calls a web services API. function FetchData() { var parameters = { EVENT_CODE: EvnCode }; $.ajax({ url: 'http://00.00.00.000/CRM/getev ...

The functionality of Jquery ceases to work once a setTimeout function is implemented

I need some help getting a series of functions to be delayed by 2 seconds using setTimeout. For some reason, whenever I try to implement this, the code stops executing altogether. I've double-checked the syntax and everything seems fine because it wor ...

Attempting to integrate AngularJS with the CodeIgniter framework

I am currently facing an issue while trying to integrate AngularJS with Codeigniter. Despite not receiving any errors, the data is not displaying as expected. I am eager to learn how to develop a RESTful application using AngularJS and Codeigniter. If anyo ...

Exploring the Functionality of ngMousedown and ngMouseup in AngularJS

Is it viable to apply ngMousedown to add a class to a div, and then use ngMouseup to remove the class once more? Currently, I am utilizing ng-mousedown="activateClass()". Within the activateClass() function, I modify $scope.className="data-active", which i ...

"Directional Light in three.js that Tracks Alongside the Camera

I'm encountering an issue with Three.js and lighting that follows a camera. I am utilizing orbit control for mouse movement. In release 66, the following code used to function properly: light = new THREE.DirectionalLight( 0xffffff, 1 ); lig ...

styling a flex container with aligned text and buttons

I'm attempting to align text on the left and button controls on the right within a display: flex div. <CustomFieldContainer> <StyledWellContainer> <FieldDetails key={id}> <H4 bold>{label}</H4> <Styled ...

Bizarre Incident Management

My latest project involves a simplistic website featuring arrow images (png) positioned on the left and right sides with fixed placement, allowing users to navigate to the next page. However, an issue arises where the cursor seems unable to select the an ...

Extracting information from an external website in the form of XML data

Trying to retrieve data from an XML feed on a remote website , I encountered issues parsing the XML content and kept receiving errors. Surprisingly, fetching JSON data from the same source at worked perfectly. The code snippet used for XML parsing is as f ...

"Repeating SignalR Messages: Issue of Duplication when Stopping and Restarting

Whenever I stop and start the connection, messages sent to the client by the hub are duplicated. If I follow this sequence: $.connection.hub.stop() $.connection.hub.start() {...} and a message is sent from the server hub to the client, it is initially re ...

The error message "TypeError: self.parent.parent.context.parseInt is not a function" indicates that

My goal is to set the height of an image using ngStyle by calculating it with a Math operation in the following way: <div [ngSwitch]="tbNm?tbNm:'itm0'"> <ion-list *ngFor="let vl of scrnshot;let ind=index"> <img *ngSwitch ...

What's causing the excessive amount of white space in my image?

Whenever I include a picture of myself on the page, it creates excessive white space at the bottom. I'm not sure why this happens, but removing the image eliminates the white space. I've attempted adjusting the margins and padding, as well as se ...

Is it Possible to Alter the Title Attribute in AngularJS with ng-class?

My website currently displays an image that updates based on the user's selection from a dropdown menu. The title of the image is set to "test", but I need it to display a different message depending on which image is being shown. Can this be achieved ...

Using React, we can create a component by defining it as a constant and then

Currently, I have a React component that is created as a const and takes props. In another file, there is a function called selectChanged() {} which returns undefined every time the select value is changed. The code for the component is as follows: ... ...

Ways to steer clear of using eval for converting strings to decimal values

I currently have the fraction "1/7" and I am looking to convert it into a decimal. While I know I can achieve this using eval("1/7"), I prefer not to use eval as it is considered harmful. Are there any alternative methods to accomplish this? ...