CSS Transform animation does not work when a class is added programmatically, although it functions properly when toggling the class in Chrome

Attempting to create an animation for the transform of a div.

Below is the code with transition and transform properties in Safari:

#mydiv{
    transition: all 2.3s cubic-bezier(1, 0, 0, 1);
    transform: scale(0.5);
    background:white;
    padding:30px;
}
.visible-popup{
    transform: scale(1)  !important;
}

The div does not initially have the visible-popup class, and I am using jQuery's addClass method to add it. However, the scaling jumps to 100% without animating. Interestingly, manually toggling the class property in Chrome or manipulating the DOM in the inspector leads to a smooth animation. Why doesn't it animate when switching the class programmatically?

Answer ā„–1

Check out this sample scenario, I'm not sure of the specifics of your task, but this should help:

$("#targetDiv").toggleClass("show-popup");

https://jsbin.com/rexuza7oqi/

Answer ā„–2

Fascinating discovery! The container div of #mydiv had a peculiar class called vanish that surprisingly had no impact whatsoever. After deleting this seemingly useless class (confirmed in the style inspector), my animation suddenly began functioning as intended.

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

The use of the `/deep/` combinator in CSS has been phased out and is set to be completely removed

After updating my angular to version 4.0.0 and chrome to 62.0.3202.94, I encountered the following error message: [Deprecation] /deep/ combinator in CSS is deprecated and will be removed in M63, around December 2017. Refer to for more information. The ...

Possible rewrite: "Unable to use jQuery to add elements to data fetched through AJAX requests."

I am looking to add a button to copy code inside every div that has a class starting with language. The code is functioning properly, however, after attempting to retrieve data from the database using Ajax, the button no longer appears in the div as it did ...

Implement jQuery pagination with AJAX in PHP

Iā€™m encountering an issue with pagination where the functionality of adding products to the cart only works on the first page. When I navigate to the second page and attempt to add products, the Ajax feature fails. Is there a way to make it work on the ...

Using jQuery's `replaceWith` function to fetch data via Ajax when clicking on a table cell

Currently, I am working on a code that I would like to implement in a specific way: There is an HTML table labeled A, and when a user clicks on the first cell of a row, it triggers a replacewith function using jQuery. The idea is that from the clicked cell ...

Problem with jQuery image gallery

Currently, I am in the process of creating a simple image gallery that enlarges an image when it is clicked. To achieve this functionality, I am utilizing jQuery to add and remove classes dynamically. $(".image").click(function() { $(this).addClass("b ...

How to verify if a node contains plaintext with jsoup?

Is there a way to determine if a node in jsoup has plain text without including link text, instead of using the Element.hasText() method? Any suggestions would be greatly appreciated. Thank you ...

A guide on retrieving form data as a JSON object array in PHP

I am utilizing jQuery Ajax to send form data to a WordPress function. Upon receiving the data in the PHP function as a string, for example "navn=A&navn2=B", I make use of the explode() function to access individual form elements. I believe there must ...

Tablet-friendly dropdown menu

Seeking advice on implementing @media queries for tablets with a width of 991px. Currently, the CSS file is optimized for mobile devices but needs adjustments for tablet responsiveness in the dropdown menu. I attempted the following CSS code: @media (max ...

Autocomplete Dropdown Options

I am trying to create a dependent autocomplete drop-down that displays suggestions based on any typed letter, rather than just the first letter. For example, if I type "Yo," it should show "New York" in the dropdown. Below is the code I have been using, ...

Tips for creating fonts that adjust depending on the length of characters

Is there a way to adjust the font size of a paragraph based on the space available in its containing div, depending on the length of characters? For instance: p{ font-size:15px; } <div class="caption"> <p>Lorem ipsum dolor sit amet, consect ...

Is there a way to prevent navbar links from wrapping when closed with CSS?

Upon closing my side navbar, I encountered an issue where the links warp to the size of the navbar. I am seeking a solution to keep the links (highlighted in pink in the image below) the same size without warping. Is there a CSS technique to achieve this? ...

Unable to link JSON response to input field using jQuery AJAX (MVC 4)

I am facing an issue with binding JSON values to a text box. Despite searching online, I haven't been able to find a solution for this. Here is the code that I am using: JQuery: $(document).ready(function () { $('#Email').mousemove(functio ...

Adjust the dimensions of the thead, tbody, and td elements on the fly

I've implemented this property in a .css file on the table shown below and there are 9 records. .fixed tbody td, thead th { width: 5.2%; float: left; } In my scenario, when there are 4 columns, the width should be 23.2%; for 5 columns ...

The jQuery onchange event does not remove the disabled attribute from HTML elements

I have been experiencing some difficulties trying to remove the disable attribute from an HTML document using the prop method. Here is a snippet of my HTML code: <form> <!-- Add your HTML code here --> </form> Currently, I am only using ...

Would it be expected for these two JQuery functions to exhibit identical behaviors?

If I have the following two JQuery functions - The first one is functional: $("#myLink_931").click(function () { $(".931").toggle(); }); The second one, however, does not work as expected: $("#myLink_931").click(function () { var class_name = $(thi ...

Creating a vertical scrollable container that spans the full height of the PDF document

I am currently working on embedding a PDF file into my website. I'm trying to hide the status bar, including download buttons and page numbers, through some clever techniques so that I can control them externally. My goal is to be able to redirect use ...

Error: Data type exception encountered in JSP file

Currently, I am developing a web application that involves generating a table dynamically using Ajax. The data for this table is retrieved from the database. Below, you can find the code snippets related to this functionality. Index.jsp <html> <h ...

What is the best way to align an image with the background of a div element?

Currently, I am attempting to create a page header that includes an image. To achieve this, I am using a div: <div id = "header"> </div> To set the background image of the div, I have added the following CSS: #header{ background-image: u ...

Set the height of the main div container to a fixed size

I am facing an issue with my div container (mapInfo-Container) which contains multiple div blocks. I want the container to have a fixed height of 250px, and be scrollable for any content exceeding this height. Here is the code snippet: http://jsfiddle.net ...

text field remaining populated

I have a form where the input fields clear when they are clicked on. It works well on most pages, but there is a specific type of page where it is not functioning properly due to the presence of another javascript running. - issue observed // On this pa ...