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

What is the process for obtaining the hash of every hyperlink?

I'm currently working on implementing an active link state based on scroll position for each section. My goal is to extract the hash value from the link. The issue I'm facing is that when I run the line 'console.log($(this).eq(i).hash);&ap ...

The datalist component in AngularJS is not receiving any data

I am struggling with a code in AngularJS, where I have simple HTML and its controller mapped in my state file. main.html <input class="serialSearch" data-ng-placeholder="Serial #" data-ng-model ="serialNum" list="suggestion"/> <datal ...

Using an external HTML file to import a template into Vue.js single file components

I've been tackling a Vuejs project that involves using vue-property-decorator in single file components. I'm trying to figure out how to import the template from an external HTML (or different) file, but so far I haven't found a solution. I& ...

How to Ensure the Security of JSONP?

Currently, I have a script that utilizes JSONP for conducting cross domain ajax calls. While it is functioning effectively, I am pondering if there is a method to hinder other websites from accessing and retrieving data from these particular URLs. My goal ...

Looking to retrieve all information related to a specific product_id by searching and selecting it in the form field?

I'm currently working on an Inventory management system and facing a challenge with the search query functionality. The tables I have set up are: products product_purchases product_sales My goal is to retrieve product details from the "products" t ...

Generate dynamic forms utilizing JSON data

I am in the process of developing an application that enables users to answer questions about themselves. The questions are being retrieved from an API. My next step is to generate a form with these questions as entry fields. I am currently utilizing a met ...

Exploring the synergies of Remark and Rehype plugins alongside MDX in Next.js powered by @next/mdx

I’ve been experimenting with Github Flavored Markdown using @next/mdx, but I’m struggling to understand how to use plugins alongside the code. Here’s a breakdown of what I’ve attempted so far: (I’m following the instructions from the Next.js Doc ...

"Unable to Access Account: PHP Login Script Failing to Log Users In

I've encountered a login issue with my website script that I can't seem to figure out. The script is designed to log users in after they input their username and password, but for some reason, even with the correct credentials, authentication fai ...

Customized function enabling dynamic menu display based on varying screen dimensions

Looking for assistance with JS and jQuery as I am relatively new to it. Any help would be greatly appreciated... I'm currently working on a responsive header where I want to implement onclick functions for mobile and tablet resolutions only. I' ...

Determine the id value by selecting spans within a div using jquery

I am looking to extract the id value from the spans. Many thanks, Jean ...

How can I update a dropdown menu depending on the selection made in another dropdown using Angular

I am trying to dynamically change the options in one dropdown based on the selection made in another dropdown. ts.file Countries: Array<any> = [ { name: '1st of the month', states: [ {name: '16th of the month&apos ...

Issue with displaying content within a custom element for children was not seen

The content within the 'Child content' span is appearing in the Light DOM, but for some reason it's not being displayed on the actual page (refer to the screenshot provided). Does anyone have any insights as to why it might not be visible? ...

Changing the animation associated with a hover action - tips and tricks!

My navigation header includes links to various websites, some of which are displayed as drop-down menus. I have implemented an animation and style change on hover to visually indicate the active link and display all available options in case of a dropdown ...

Angular handling multiple query parameters

I am looking to implement multiple path routes for a component named Component2. I want the functionality to be similar to GitHub's file navigation within repositories, but I do not want to hardcode a path like 'source/:filePath/:filePath/:filePa ...

Issues with ng-click functionality not activating on <li> HTML elements

I've been attempting to add ng-click functionality to my list, but it's not working as expected. I've tried adding the ng-repeat directive and also without it on li elements. Here is the snippet of HTML code: <ul class="nav nav-tabs"&g ...

Website layout looking unique due to pixel width adaptation from standard width

I'm currently working on a website with full width design. On my computer, the website displays as full width, but on other computers it shows extra space on the sides. How can I ensure that this website is truly full width? .wrapper_boxed { wid ...

Is it possible to combine two conditions using CSS?

Hello, I have a question about CSS. In my navigation bar, I have 3 links with different styles: #p1 { font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 45px; font-weight: bolder; color: #999999; text-dec ...

Using jQuery to modify text color

I'm new to learning jQuery and I want to make a text color change on my website when the user scrolls. The piece of text is inside a div with the id #headerTitle in my CSS file. This is the current code I have: $(document).ready(function(){ $(w ...

Is it possible to use JavaScript to click on a particular point or element within a canvas?

Is there a way to trigger a click at a specific point on a canvas without direct access to the code that generates it? I've attempted using coordinates, but haven't had any success. Any alternative suggestions would be appreciated. UPDATE: To pr ...

Transitioning from using lerna to adopting pnpm

We are in the process of transitioning our project from Lerna to PNPM and we currently have a script that we run. Here are the commands: "postinstall": "npm run bootstrap" "bootstrap": "lerna bootstrap --hoist", &quo ...