When the screen is tapped, the background color transforms into a different shade

Is there a way to change the background color of a specific div when touching it? I have tried using the following code:

.x-list-item:active {


background: #870000 !important; /* fallback for old browsers */
background: -webkit-linear-gradient(to left, #870000 , #190A05) !important; /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to left, #870000 , #190A05) !important; /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */


}

However, after touching the dive and dragging it, the background color remains the same. I then tried using the following properties:

-webkit-tap-highlight-color

 .x-list-item {

    -webkit-tap-highlight-color: #870000 !important;
    -webkit-tap-highlight-color: -webkit-linear-gradient(to left, #870000 , #190A05) !important; 
    -webkit-tap-highlight-color: linear-gradient(to left, #870000 , #190A05) !important; 


    }

Unfortunately, the styles are not being applied. The div color does not change. Can someone explain why this is happening and provide a solution?

Answer №1

To easily modify the background of .x-list-item upon clicking, you can utilize the following code snippet assuming you have the jQuery library included in your project:

 $('.x-list-item').on('click', function(){
      $('.x-list-item').css({background: 'red'});
    });

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

Seeking consent for HTML5 Geolocation API usage in web applications: A step-by-step guide

Seeking help with using html5 geolocation this.getCurrentLocation = function(callback) { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (pos) { callback({ 'la ...

Adapt appearance according to the length of the text

Currently, I have an array that stores multiple strings based on displayed charts. My objective is to find the longest string within this array. So far, this task has been executed without any issues. The code snippet for this process is as follows: var ...

What is the best way to manage these interconnected Flexboxes when using align-items: stretch?

Trying to put this into words is quite challenging, so I created a simple diagram for better understanding: https://i.stack.imgur.com/TMXDr.png The outer parent uses flex with align-items:stretch to ensure that both col 1 and col 2 have the same height. ...

The process of uploading images to a server by making an AJAX call to a PHP file

I have an input file and I want to upload the attached file to the server with a message saying "uploaded successfully" when I click on the upload button. However, I am getting a "file not sent" message. (The uploaded images need to be saved in the uploa ...

Applying box-shadow to tables and collapsing borders with border-collapse property in IE!

The box-shadow property does not function properly in Internet Explorer when the table has a border-collapse: collapse style applied to it. ...

What's preventing canvas from working offline but functioning properly on the TRYIT platform?

I have created some canvas-related code that works perfectly on TRYIT editor, but it fails to work locally when I copied the code into a file and tried to run it. This code is designed to take an image, set the width and height of a canvas based on that i ...

When the start button is pressed, the page will automatically refresh until the stop button is clicked. Learn how to track the duration of the start button press

I have a table of data that I need to continuously update with the latest values from the database. In order to do this, the page automatically refreshes every 10 seconds. The updating process is triggered when the user clicks the start button and stops ...

Having trouble getting my ReactJS page to load properly

I am currently linked to my server using the command npm install -g http-server in my terminal, and everything seems to be working smoothly. I just want to confirm if my h1 tag is functional so that I can proceed with creating a practice website. I have a ...

PHP Debate: Static vs Non-Static - Which is the Superior Choice?

Static and non-static functions as well as class properties really had me puzzled when I attempted to launch my website. Could someone clarify whether it is preferable to have the entire website coded using static functions rather than relying on non-stat ...

MailJet experienced a template language issue while trying to send a message with Template [ID]

While running a test on a MailJet email template that includes a basic custom HTML code block, an error occurs in the received test email. (The live preview in the browser functions correctly) From [email protected]: An issue with the template lang ...

Sticky positioning is not maintaining its position at the top

I've noticed a strange behavior where, when I scroll down, the yellow box goes on top of the blue box. I have set both boxes to have a position sticky so that they should stay in place and not overlap. However, I want only the orange box to be scrolla ...

associating the highlighted text with a specific attribute of the selectbox

Using my coding skills, I developed a small application that enables users to add text from a textarea to a div block. My goal is to prevent the appended text when the user clicks on the yellow div, and highlight the selected text properties (such as font ...

Can we implement CSS that is based on the latest ancestor?

Incorporating CSS, my goal is to implement varying styles to the element labeled with the class test. However, the style should differ based on whether it is situated within an element of class a or class b: <div class="a"> lorem <div class=" ...

JavaScript: Update Div Background Automatically

My website has an advertisement section that works fine for most users. However, if a user has an ad-blocker enabled, the advertisement doesn't display and instead, an empty area appears on the site. To address this issue, I plan to add a background ...

Resolving CSS Fluid Image Problem

Even though my site background is responsive and functions well, I am encountering problems with the images. I want them to appear "fixed" in the same position as the background, regardless of resolution changes. For example, resizing the browser from 990p ...

Tips for Optimal Dropdown Menu Placement

The tabs in my menu seem to be refusing to move closer to the left side of the menu. I've tried removing padding elements and adjusting other settings, but there still remains an awkward space between the edge of the menu and the tab text. Additional ...

What's causing my struggle to override the bootstrap nav-link class in next.js?

I am facing an issue where I need to customize the active state of bootstrap .nav-link in the code snippet below: <li className="nav-item"> <a className={`${styles.navLink} nav-link`} role="tab" data-to ...

How can I make the Struts2 iterator function correctly?

Using the Struts2 <iterator> tag in a JSP to display values, the method is being called but no results are appearing on the page. All the necessary data is printing in the console, but not in the JSP itself. The call made is localhost\listAddCo ...

Adjust the initial position of the slider handle on the WooCommerce widget price filter

Is there a way to enhance the visibility of the woocommerce widget price filter by adjusting the starting position of the slider handle? For example, shifting it 10% towards the right from the beginning of the range bar. Check out the comparison of positi ...

Any ideas on how I can enable rotation of SVG images within a Bootstrap 4 Accordion card with just a click?

I'm working on a Bootstrap 4 accordion card that has an SVG arrow image in each header. I am trying to make the arrow rotate 180 degrees when the header is open, and return to its initial state when it is closed or another header is opened. Currently, ...