Focus CSS and JS on particular tables

I am encountering an issue with applying responsive features to only 2 out of 3 tables on a page. The third table is meant to remain simple without any additional styling or javascript effects. Despite my attempts at using classes and examining the script, I have been unsuccessful in resolving the problem.

In this CodePen demonstration, I have recreated the issue for better understanding. Essentially, when the screen size drops below 1024px, the two larger tables adapt appropriately while the smaller table inherits unwanted styles causing layout issues. The provided script includes functionality which seems to affect all tables uniformly.

$('ul').on('click', 'li', function() {
var pos = $(this).index() + 2;
$('tr').find('td:not(:eq(0))').hide();
$('td:nth-child(' + pos + ')').css('display', 'table-cell');
$('tr').find('th:not(:eq(0))').hide();
$('li').removeClass('active');
$(this).addClass('active');
});

// Initialize
var mediaQuery = window.matchMedia('(min-width: 640px)');

// Add Event Listener
mediaQuery.addListener(selectElement);

// Function Event Listener
function selectElement(mediaQuery) {
if (mediaQuery.matches) {
$('.sep').attr('colspan', 5);
} else {
$('.sep').attr('colspan', 2);
}
}

// On Load
selectElement(mediaQuery);

Any insights or advice on how to target the specific tables individually would be highly appreciated. Currently, modifications intended for the larger tables inadvertently impact the smaller one as well.

Answer №1

If you're looking to enhance your CSS, consider incorporating the following code snippet outside of your media query. It worked perfectly for me - check out the CodePen link below:

table.si-cov-tb td{
 display: table-cell;
}

View on CodePen

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

Tips on automating clicking the cookie button using Selenium?

Currently, I am attempting to extract data from the following website. I need to access various subpages, but some of them are hidden behind a "load more" button. I decided to use Selenium to click the button, but I am encountering difficulty with getting ...

When a button is clicked, a Chrome Extension will display a new window

I have developed a Chrome extension that includes a button. When the user clicks on this button, it launches a pre-created HTML page. Here is the code for the button: var btn = document.createElement("BUTTON"); var t = document.createTextNode("Clic ...

The alignment in the center is lacking consistency

Is anyone else experiencing issues with the duration and current time text not staying centered vertically? It seems to be a hit or miss, sometimes centering correctly and other times not. What could be causing this inconsistency, especially when no code c ...

Unable to remove any even numbers from my array

Having trouble removing all the even numbers from this array. Can't seem to get them all out of there, not sure why. var numArr = [3,45,56,7,88,56,34,345]; for (var i = 0; i < numArr.length; i++) { if (numArr[i] % 2 === 0) { ...

Combining Google app endpoints with a phonegap app: Step-by-step guide

I've been working on a Phonegap client application and have developed all the necessary web services using Google Endpoints. However, I am facing an issue with using the API. In my index.html file, there is this script: <head><script> ...

Empty space on the side of the menu bar

In my current project, I am working on creating a menu bar with the container named #menu. The CSS for this container includes properties such as border: 0px; margin: 0 auto; position: relative; display: inline-block; width: 100%. However, I encountered a ...

When I attempt to press the shift + tab keys together, Shiftkey is activated

Shiftkey occurs when attempting to press the shift + tab keys simultaneously $("#buttonZZ").on("keydown",function (eve) { if (eve.keyCode == 9 && eve.shiftKey) { eve.preventDefault(); $("#cancelbtn").focus(); } if (eve. ...

Processing PHP forms with dynamic form inputs

Have a form with the capability to add multiple input fields for ordering pictures by picture number. A customer could potentially order anywhere from 1 to 100 pictures. How should I handle this in PHP? Creating up to 100 $_POST[] variables for each poss ...

Issue with jqGrid Multiple Selection

When constructing my jqgrid, I utilize the following code: multiselect: true This enables a check all column. However, clicking the check all checkbox (located at the header) selects all checkboxes, but does not click the checkboxes in each row. You can ...

Obtaining a value in a non-function JavaScript code block is achievable by

I'm currently studying the Box Plot example in Mike Bostock's D3 gallery and I have some questions. Here is the code snippet from an Observable notebook: Within this code snippet, there is a block of code that doesn't seem to be a function ...

Decode PDF417 barcode images with ease using HTML and JavaScript on both desktop and mobile web browsers

Looking to utilize JavaScript to decode PDF417 type barcode images? If you're encountering Zxing plugin issues in mobile browsers but it works well on desktop browsers with https://github.com/PeculiarVentures/js-zxing-pdf417, consider alternative sol ...

Increasing the height of a div in a vertical direction

Having an issue with divs not expanding vertically when there are anchors with padding inside. The explanation isn't the clearest, so I've recreated the problem here: http://jsfiddle.net/uF6KN/3/. Essentially, I want the blue anchors to align wi ...

Executing code before a component mounts in ReactJs: What to do now that componentWillMount is no longer recommended?

Before my component mounts, I want to redirect the user to the home page based on a condition: componentWillMount(){ console.log("componentWillMount is called.") let userHasNotChosenOpportunity = true if (userHasNotChosenOpportunity) ...

continuous monitoring of sessionStorage

Currently, I am working on code that triggers a pop-up when the mouse leaves the browser. The functionality is partially working as the alert pops up and session information is stored, but only after refreshing the browser. var key = JSON.parse(sessionSto ...

What is the best way to call the app.js function from an HTML page in an Express.js environment

Is there a way to trigger the function init() { // } located in app.js from an HTML page? <a href='javascript:init();'> Trigger init </a> The issue with the code above is that it searches for function init() only on the client side ...

An issue has been discovered with the Search function as JavaScript's Array.filter() and .map() methods are not functioning properly, resulting in

Currently, I'm working on integrating a search feature into my Flask application that will display the cities entered by users and are present in the JSON API results of a weather API. I am following a tutorial and have used a code similar to this: h ...

Guide on how to navigate to the bottom of a div element using Selenium Webdriver

My current project involves a unique challenge where there is a specific div element on the webpage that acts as a popup dialog when a link is clicked (similar to Facebook reaction dialog boxes). To automate tests for this scenario, I am using Selenium We ...

Manipulate markers on Angular Google Maps by dragging them with the mouse

I am currently working on an angular project that includes incorporating a Google map using angular-google-maps. The user is able to add multiple markers on this map. app.js angular.module('mapAngular', ['uiGmapgoogle-maps']) .cont ...

How can we use Bootstrap to ensure that items in a div are aligned horizontally on larger devices and vertically on smaller devices?

I am currently working on creating a div that contains some information, similar to the layout used on the Coinbase website. However, I am encountering issues with styling as I want this div to be responsive - horizontally aligned on larger devices and ver ...

What could be the reason for 'selected' not appearing?

Can anyone explain why the 'selected' attribute is not appearing in my <option value=""> element? <p> <select name="images" class="dropdown"> <option value="empty" <?php if(isset($_GET[ ...