The issue of selecting multiple classes simultaneously is not being resolved

Here is my JavaScript code snippet:

$('.normal-box').click(function(){
    //unique row id
   var id = $(this).data('row-id');
   //its index according to the content array
   var index = $(this).data('index');
   //which card does this row belong to
   var card_name = $(this).data('id');
   var card;
   console.log(id) //el id de noten es de por si "link last_updated" concatenado
   switch(card_name){
       case "noten" : card = Unidos.CardManager.getCard(card_name); break;
       case "nachricht" : card = Unidos.CardManager.getCard(card_name); break;
       default : return false;
   }
   card.resetPriorityWhenClickedOn(id);
});

And here is the HTML part:

 <script id="nachricht_card_row_template" type="text/html">
            <div class="normal-box" data-row-id="{{id}}">
                        <div class="img-box">
                            {{#if channel.image}}
                            <img src="{{channel.image}}" vspace="3">
                            {{/if}}
                        </div>
                        <div class="subtitle-box" id="nachrichten-subtitle-box">
                            <span class="options-title" id="title-text">{{channel.name}}</span>
                        </div>
                        <div class="side-text-box">
                            <span class="side-text">{{formatDate datetime}}</span>
                        </div>
                        <div class="small-text">
                            <div class="normal-text"><span class="text-formating">{{text}}</span></div>
                        </div>
            </div>
        </script>

This is the CSS section:

.normal-box{ /*Container of other tiny boxes*/
    height: 70px;
    border-bottom: 1px solid;
    border-bottom-color: gainsboro;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.5s ease 0.3s;
}
.normal-box.show{
    opacity: 1;
}

If you notice in the last part, I am facing a challenge selecting elements with multiple classes like .normal-box show. Here are some things I have tried:

$('.normal-box, .normal-box show)
$('.normal-box, .show)
$('.normal-box.normal-box show)
$('.normal-box.show)

Unfortunately, none of them seem to work for me. Any assistance would be highly appreciated.

Answer №1

Typically, when you use $('.normal-box'), it will select any element with the class normal-box. However, if these elements are added dynamically, you will need to utilize event delegation like so:

$(document).on('click', '.normal-box', function(){
   //Add your code here
});

I trust that this explanation proves useful.

Answer №2

Give this a shot:

$('.regular-container.display');

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

Why is the AJAX request not functioning properly after using jQuery's hide method?

It seems that the first AJAX call works fine when I hide the div, but subsequent requests are not going through. a) Clicking on the signup button triggers an AJAX request to display the details. b) Pressing the hide button hides everything within that di ...

Struggling to properly line up the baselines of navigation list items that are styled as circular elements using CSS

I have transformed my navigation menu into a series of CSS circles with text inside. The issue I am facing is that the text spills out unevenly based on the amount of content in each circle. To address this, I used a JavaScript solution to center-align the ...

jQuery event handler for changing and blurring elements

Imagine a situation where you only want an event to be triggered when you exit an input field. This is because the event initiates a type of request, like an ajax postback, that updates the input fields. If a change event were used, it could create an infi ...

What are the steps for rearranging a table column?

I am trying to show a text file in a table and allocate some code to each entry. I can display the text file. I can assign the code for each record (though this part is still under development). However, I have encountered an issue. The columns of the t ...

Angular 9 is throwing an error that specifies that the options provided in the @ViewChild decorator must be in

After successfully upgrading my Angular project from version 8 to 9, I encountered an error when trying to run the project on localhost or build it. The error message states: ERROR in @ViewChild options must be an object literal The @ViewChild syntax that ...

Varied approaches to managing responsive layouts

I am encountering an issue with the responsive design of a website I am currently developing. Scenario: The website features 3 different layouts for Desktop, Tablet, and mobile devices. These layouts consist of similar components with slight CSS adjustmen ...

How to extract a specific part of a string with regular expressions

I am currently working on a function to search for a specific substring within a given string. // the format is <stringIndex>~<value>|<stringIndex>~<value>|<stringIndex>~<value> var test = "1~abc1|2~def2|1~ghi3|4~jk-l4 ...

"Aligning two images side by side in a horizontal

[enter image description here][1]I am trying to place two images on my website, but I am struggling to vertically align them properly. I have attempted using line-height and vertical alignment, however, I cannot seem to pinpoint the issue or identify any m ...

Is there a way to access the rear camera on a mobile device using webcam.js?

Currently, I am utilizing webcam.js from the following link: https://github.com/jhuckaby/webcamjs. When accessing the website on mobile devices, the front camera tends to open by default. My objective is to switch this default setting to access the rear ...

My HTML document is not displaying the JavaScript variable as expected

I have created a JavaScript function with several variables and attempted to test it to display the variables in my HTML document. However, I am facing an issue where the variables do not appear as expected. Specifically, I am trying to insert the variable ...

Tips for getting links to wrap or scroll within a column element in Angular

In my row element with two columns, I am facing an issue where the first column sometimes overlaps the second column due to a very long link in the problem.problem_description section. I want to find a way to have long links wrap or be scrollable. However, ...

Align the OutputText centrally within the Div

I am having trouble centering the output from my PHP code. The output is just words that form a sentence, but no matter what I try, I can't seem to get it centered properly. Each PHP function simply echoes out a word like 'banana' as a norma ...

Having trouble with the placeholder blur feature on images in Next.js?

Within my website, I have a dynamic route set up as /titles/[slug].js. Upon initially navigating to this route, everything functions as expected - the placeholder blur effect displays on all images and animations triggered by react-intersection-observer wo ...

Guide on implementing route segments using $location.path() in Angular

I am currently utilizing the routesegment provider for routing within Angular. I have a question regarding how to initiate a URL call using $location.path(). Here is my code snippet for reference: FinancialGameApp.config(['$routeSegmentProvider& ...

Are there any options available for customizing the animation settings on the UI-bootstrap's carousel feature?

If you're interested in seeing an example of the standard configuration, check out this link. It's surprising how scarce the documentation is for many of the features that the UIB team has developed... I'm curious if anyone here has experie ...

modify the calculation in real-time by updating the text box with ajax

In this scenario, the input and display page are dynamically generated from PHP code. enter code here <div>Aeroplane</div> <input id="Item556" type='number' onchange="funCal('Item556', this.value, 'Aeroplane&apos ...

What is the reasoning behind jQuery UI employing CSS classes as opposed to pseudo-classes?

In this detailed explanation found on this website, it is discussed why jQuery UI uses CSS classes like .ui-state-active that are applied through JavaScript, rather than utilizing existing CSS pseudo-classes like :active. What is the reasoning behind thi ...

Show brief tags all on one line

This image showcases the functionality of the site, specifically in the "Enter a code" column where users can input data using TagsInput. I am seeking to enhance this feature by ensuring that shorter tags are displayed on a single line. While I am aware th ...

Responsive images in CSS3/HTML5 are designed to adapt to different

I am looking to implement responsive image sizing based on the webpage size. My images come in two different sizes: <img src="images/img1.jpg" data-big="images/img1.jpg" data-small="images/img1small.jpg" alt=""></img> The data-small image has ...

Encountered a SyntaxError stating 'Unable to use import statement outside a module' while attempting to utilize three.js

I'm facing difficulties with incorporating three.js into my project. Initially, I executed: I am referring to the guidelines provided here: In my VS Code terminal for the project folder, I ran the following command: npm install --save three Subsequ ...