Only animating one object from a class at any given time

Using CSS to flip images on click works perfectly across all browsers, but runs into issues when there are multiple instances on the same page. The animations occur simultaneously for all instances.

Is there a way to target and animate only one instance at a time?

Check out this link for reference.

$('.card').click(function(){
    $('.card').toggleClass('applyflip');    
}.bind(this));

Appreciate any help, thank you!

Answer №1

To refer to the element that was just clicked, use $(this).

When a '.card' is clicked, toggle the 'applyflip' class on it by using $(this).
$('.card').click(function () {
    $(this).toggleClass('applyflip');
});

Check out this Fiddle for more information.

Answer №2

When working within the click handler, make sure to utilize this in order to point back to the specific element that triggered the event:

$('.card').click(function () {
    $(this).toggleClass('applyflip');
});

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

From structured CSS to streamlined LESS syntax

Being a UX designer, my goal is to streamline my workflow. I aim to transition from HTML to well-structured CSS to LESS as efficiently as possible. The concept is to input HTML, generate CSS, compile it to LESS, style it, and then recompile it back to CSS ...

Attempting to arrange six images in a row using dividers

Having trouble aligning six images (2 per row with text in between) to the center of your webpage? Don't worry, we've got you covered! Check out the screenshot attached for reference and let us know how we can assist. Click here for a snapshot of ...

Dropdown in Angular JS is displaying incorrect values in the options

I am a newcomer to AngularJS and encountering an issue with populating a dropdown. Within a foreach loop of data retrieved from the server, I have created an array of user data: $scope.Users.push( { userid: ...

When the user clicks on a checkbox, jQuery should have the ability to retrieve the data from a table with 9000 rows

I am in need of a straightforward example that demonstrates how jQuery can fetch the contents of a table with more than 9000 rows. When the user clicks on the checkbox next to a table row, the checked rows should be displayed on the same view page. Can you ...

disable hover effect

Kindly visit the link below and click on 'Story': Upon mouseover, the animation can be observed: How can I remove this effect? The CSS I am using for this is as follows: .storypageThumb1 { float:left; width:175px; height:91px; ...

Tips for eliminating the bottom border on a nav-tab in Bootstrap 4

When a vertical navigation menu item is selected, a border appears below the item. How can I remove this border? .nav-tabs li, .nav-tabs li a { border-bottom: none; } Here is a picture of the border: ...

Is there a way to prevent jQuery.ajax() from displaying errors in the console?

I have set up a jQuery JSONP request to monitor the status of a resource based on its URL. In case the resource is not accessible or the server goes down, my ajaxFail() function takes care of updating the display. function fetchServerStatus(service, host) ...

AngularJS - Custom directive to extract a property value from an object

Currently, I am using the following for loop to retrieve the parent category: angular.forEach(queryTicketCategories, function(category) { if(category.id === $scope.ticketCategory.parentId) { $scope.parent = category; } }); I am looking fo ...

When working with a barcode font in Chrome, using style.fontFamily may not be effective, but utilizing className can achieve the desired result

Take a look at this HTML snippet: <style> .barcode { font-family: 'BC C39 3 to 1 Medium'; } </style> <div><span id='spn'>1234567</span></div> This code will apply a barcode font style: <script> ...

Turn off the text cursor when inside a specific div block

Check out these two fiddles: fiddle 1 and fiddle 2 The only variation between the two is a single CSS property in .category -webkit-user-select: none; In fiddle 2, when you click and drag an element, the cursor remains as a pointer instead of changing t ...

Using jQuery to compute variances between two tables

If you have come across this question before, kindly direct me to where I can find the answer. I am in the process of setting up a form in a "spreadsheet" style that consists of three separate tables. The first table will list employees along with their s ...

How to troubleshoot incorrect div width detection by jQuery in Bootstrap

My asp.net mvc4 project utilizes bootstrap for markup and jquery for client side functionality. <div class="row"> <div class="col-md-4 container" id="cont"> <div class="row overlay_container" id="overlayCont"> <div class=" ...

Utilize Bootstrap's scrollspy and fixed navigation to incorporate an offset

I've successfully implemented a fixed navigation with scrollspy and smooth scrolling: HTML <body data-spy="scroll" data-target=".navbar-collapse"> <!-- ---------- Navigation ---------- --> <div class="navbar navbar-fixed-top" role="na ...

Angular input range slider that automatically rounds decimal values from the data bindings

I've implemented a range slider within an Angular form to capture and display recorded values. <input [formControlName]="object.id" [id]="object.id" type="range" [(ngModel)]="object.answer" [step]="objec ...

Getting the value of a table cell within a row that has a specific value in another cell

Looking to extract the links from a table cell in rows where a specific value is present. This concerns a row in a table where I aim to retrieve the link from the "Match" division if the "Home team" division holds a specific value. There are multiple rows ...

Strange occurrence: Ajax event running multiple times

Here is the code that I am working with: $( document ).ready(function() { $('#myModal1').on('shown.bs.modal', function (event) { $(".save_profile_name").click(function(){ var pro_id = $("#profile_id").val() ...

Create a typewriter effect that mimics the backspace feature by allowing overlapping characters

I am interested in creating a simulation for the vintage LGP-30 computer. This will involve input and output on a simulated Friden Flexowriter typewriter. One unique feature of the typewriter is that pressing the backspace key merely shifts the print head ...

Utilizing LocalStorage for storing the most recent input value

Is there a way to set and retrieve the last input value using JavaScript or jQuery? I want to implement an onkeydown function for an input field that updates the input value, and then each time the page is loaded, that value is displayed. <input type ...

Output the following by using the given format: *a* -> *a1**aabbbaa* -> *a2b3a2*

I am a beginner in JavaScript. Could you please explain how to achieve the following output? * "a" -> "a1" * "aabbbaa" -> "a2b3a2" I attempted using a hash map, but my test cases are failing. Below is the code I have writt ...

Unable to retrieve custom CSS and JS files hosted on the server

Encountering Server Issue My server is returning a 404 NOT FOUND error when trying to access my static files: css and js. In IntelliJ IDEA, the path appears correct as shown in the image https://i.stack.imgur.com/nTFv9.png. However, upon accessing the pa ...