Tips for emphasizing all div elements located within two specific div elements

Imagine having a series of 10 divs numbered from 1 to 10, and then selecting div 2 and div 7. The goal is to highlight all the divs between these two selected divs once the ending div is chosen after the starting div (starting div=2 and ending div=7).

Currently, I am able to select any 2 divs and have them highlighted using CSS. However, now I want to enhance this functionality to include highlighting all the time slots between the 2 selected terminals.


<div *ngFor="let todayDate of dates; let z = index" class="dateBox">
    <div style="margin-bottom: 10px;">{{fullDate[z] | date: 'fullDate'}}</div>
    <div class="" *ngFor="let time of ScheduleTime; let i = index">
        <div *ngIf="todayDate == time.date">
            <div class="timeSlots" [ngClass]="{'startClass': time.hours == st.sh && time.minutes == st.sm && startDate == time.date, 'endClass': time.hours == et.eh && time.minutes == et.em && startDate == time.date}" (click)='timeSelector(time,i,todayDate)'>
                {{time.hours}}:{{time.minutes | zero}}
            </div>
        </div>
    </div
</div>

I already have the indexes of both selected divs. Is there a way to leverage this information to achieve what I am looking for?

Answer №1

Utilizing CSS rules is another option for achieving this. You can use the selected_element ~ element selector to target specific elements based on your requirements. The selected element could be an :nth-child or you can simply assign a custom class to it. After that, you can use the lastSelected_element ~ element to style the remaining elements with default styles.

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

Is there a way to asynchronously load image src URLs in Vue.js?

Why is the image URL printing in console but not rendering to src attribute? Is there a way to achieve this using async and await in Vue.js? <div v-for="(data, key) in imgURL" :key="key"> <img :src= "fetchImage(data)" /> </div> The i ...

Communication between related components in Angular involving siblings

I am currently working in Angular 4 with sibling components, where there are no parent-child relationships, only siblings. One of the siblings is able to successfully retrieve data, particularly the ID from the URL using the code snippet below: public ge ...

Retrieving the IPv4 Address from an Express.js Request

I am currently working on setting up a whitelist for IP addresses in my API. However, when I use request.socket.remoteAddress in Express.js, I receive an IPv6 address (I believe) that looks like this: ::ffff:127.0.0.1. My main concern is how can I extract ...

Issues arise when attempting to send an HTTP request in Angular 8, although Postman is functioning properly

I am facing difficulties with getting Angular to send my data to the API backend. The API functions correctly when tested with Postman. I have set up a service for the Observable and subscribed to it in the component. My objective is to post the firstnam ...

Angular 2: Accessing the parent component from the output

I am a beginner in Angular 2 and I've been exploring ways to access the value of an attribute from a parent component using the @Output feature. Below is the code snippet: ParentPage.ts export class ParentPage { name: string; constructor(){ ...

Dragging a stack of cards in a game of Solitaire using jQuery UI

I'm currently in the process of creating a Solitaire card game using Javascript. To enable dragging and dropping functionality for the cards, I am utilizing jQueryUI. In the example provided at http://jsfiddle.net/HY8g7/1/, you can see how the cards c ...

Using the `type=file` input in Internet Explorer 11

Encountering an issue with the input type file on IE11. In IE11, the input field is displayed as two tab-able pseudo elements (text/button). Tried using the class ::-ms-browse to hide the button with display: none, but it remains tab-able. To replicate: ...

Using a dynamic image source in an Ionic 3 background

I am using ngFor to display a list of posts, each of which should have a unique background image. The getBackgroundStyle function is responsible for extracting the URL of the image from the post array. <div class="singlePost" *ngFor="let post of da ...

Click to switch Three.js model source

After experimenting with some examples, I'm struggling to change the Model Source of the OBJLoader on click due to my limited knowledge. I want to load a different model when clicking an anchor with the name of the object as the text. However, changin ...

Tips for adding responses to input fields in AngularJS

I am looking to populate data into 3 inputs based on the JSON response I receive from my node server. However, despite receiving a response, I am unable to input it into the designated fields. Controller: $scope.edit = function(id, contact) { console.log ...

The loginError variable in the ts file may experience a delay in updating its value

After entering an incorrect email and password, clicking on submit should set this.LoginError to return true in the component ts file console. However, it initially returns false, and only after clicking submit two or three times does the value finally upd ...

What is the best way to instruct Ajax to choose the specific item clicked within a list?

I am currently working on creating a list of people on vacation and I want to calculate their return date when the "Return Date" link is clicked. I have been able to achieve this, however, whenever I click any of the buttons in the list, it always passes t ...

Tips for correctly storing an async/await axios response in a variable

I am facing a challenge with the third-party API as it can only handle one query string at a time. To overcome this limitation, I am attempting to split multiple strings into an array, iterate through them, and make async/await axios calls to push each res ...

Expanding Your Django Template Abilities

Dealing with a fairly simple issue here. I've got a web page template that includes some common CSS styles at the top. <html> {% load static %} <link rel="stylesheet" type="text/css" href="{% static 'css/index.css' %}"> .... *n ...

I am keen on implementing the bootstrap template within a react project, however, I am encountering difficulties in incorporating the

Exploring how to implement a bootstrap template in React has been quite an interesting journey. After successfully importing all the necessary CSS files into my component page, I encountered an issue while trying to utilize the JavaScript files. Although ...

Tips for fixing an error encountered when running a react native project for the first time

I am encountering some errors while attempting to run this project for the first time and I am unable to resolve them. Below is the content of the package.json file: { "scripts": { "start": "expo start", "andro ...

Adding a CSS class to an HTML element using JQuery

I have a collection of tabs, and I want to dynamically add an <hr> element with the class "break-sec" when a certain class is active. This element should be placed within a <span> element with the class "vc_tta-title-text" after the text. Here ...

Utilizing Angular 2+ with the [innerHTML] property to incorporate HTML with added style attributes

I am currently utilizing Angular 2+ [innerHTML] input for inserting HTML formatting that includes style tags. Within my template, the code looks like this: <span [innerHTML]="someVar"></span> In the component file, I have defined: someVar = ...

What could be causing the font of the background text to change when CSS3 animation is applied?

Have you ever noticed a font style change in the background text when applying CSS3 animations for opacity and scale transforms? I have some text content on my page, including a "Click me" link that triggers a popup with a CSS3 animation. However, I'v ...

Access a component within an inactive carousel slide

I'm encountering a problem with the search feature in the carousel within my FAQ system. The search box is designed to locate questions within the FAQ list. Currently, when a user selects a question from the search results, they are redirected to th ...