Creating a smooth jQuery animation when concealing three columns and enlarging one to occupy the entire row

When my page loads, it displays 4 wrapper divs with the 'col-md-3' class each. However, when an expand button is clicked, 3 of the wrappers become hidden and the clicked one changes to 'col-md-12':

// Expand current wrapper to col-md-12, hide others
    $(".wrapper").each(function (index) {
        if ($(this).attr("id") === wrapper.attr("id")) {
            $(this).removeClass("col-md-3").addClass("col-md-12");
        } else {
            $(this).hide();
        }
    });

Is there a simple and fast way to add animation to this process without using the jQuery UI library in my project? I would like to have a slide left to right motion.

So far, the only solution I've found is:

$(this).hide('1000');

However, I would prefer to animate the addition of the "col-md-12" class rather than hiding the other wrappers.

Answer №1

My favorite movement is sliding from left to right.

When using JQuery, you have the ability to add animation effects to elements by:

$(this).stop().animate({
    right: '-50%'         //specify distance to move
}, 400);                 //set duration of movement in milliseconds

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

An option instead of using a pop-up window

Currently, I have a PHP script and a small form that allows users to upload image files. The user can access this feature by clicking on a button on the parent HTML page, which opens up a Pop Up Window. I understand that not everyone is a fan of 'Pop ...

Switch back and forth between two text options

Looking for a way to show only one paragraph of text at a time on a webpage? Consider using a set of buttons at the top of the page that can toggle between paragraphs with javascript or jquery. In my current project, I've implemented some code to ach ...

The optimization of paths in Gulp with Browsersync

I am facing an issue with making a file request via ajax post request. I'm trying to figure out how to properly map the file path in my ajax call to match the server's path. I can't seem to understand why it's not working (previously u ...

"Why isn't the reordering functionality functioning properly after the button has been clicked

I have a question regarding menu options that contain text and a button. I need to open the menu option when the button is clicked. Unfortunately, I am facing an issue where rerendering is not working when I click on the button. Here is the link for refer ...

Access to private members is restricted when redefining a class method

After defining a private member with #, attempting to redefine a member that utilizes this private member will result in the inability to access it: class Foo { #secret = "Keyboard Cat"; method() { console.log(this.#secret); } } ...

The specified container is not a valid DOM element

Recently, I decided to implement Redux into my React application. However, as I began setting everything up within my index.js file, I encountered an error message: https://i.sstatic.net/4kL2T.png. After some research, I learned that this error is related ...

What is the best way to position a button on the right side of a div element?

**Is there a way to position a button on the top right with white space on the left side? ** <div class="newsletter"> <button class="goup">GO UP</button> *How can I put this btn to the right with full white space??* ...

Pause for Vue variable status update

Is there a way to trigger code execution when a variable changes? For example: $store.state.AppStatus starts as "busy" when a Vue component is loaded and then changes to "ready" I want to run a bootstrap function after $store.state.AppStatus changes to " ...

Steps to effectively pass an id as a query parameter

To redirect to a new page when clicking on the edit (href link) and at the same time fetch the data corresponding to the record, this is your view code: <tr data-view-key="<?php echo $id; ?>"> <td class=""><?php echo $id; ?>< ...

Experimenting with dynamically adjusting perimeters based on the URL using Node.js

I am experimenting with changing the text color based on the URL of my Localhost. I have been trying to display this "Hello" message but seem to be missing something. What is it that I am doing incorrectly? var http = require('http'); var PORT ...

Delete footer in twitter bootstrap modal

I am having some trouble with removing the footer from my modal. Although I manage to remove the contents, there is still space being taken up by the footer. Below is the code snippet I am working with... <div class="modal hide fade"> <div cl ...

Retrieved information from Firestore to set as the initial value for my useState hook, but I keep receiving an undefined value

I'm facing an issue where I want to use the fetched data from Firestore as the initial value of my state using useState, but it always returns undefined. This is because when updating a user profile, I need to know which property has been edited or up ...

Activate scroll function exclusively upon hovering over specific object

I am working on a page with an object that allows users to zoom in and out. I want to create a special zoom function that will be triggered when the user scrolls while their cursor is hovering over this object. If the cursor moves away from the object, th ...

Top Jquery File Upload Tool (ajax)

I've come across various Jquery-Ajax-Upload scripts, but I'm curious to know which one you currently find to be the most stable and reliable? Thanks in advance! Peter ...

Need help troubleshooting Bootstrap not functioning correctly in a PHP file within the layout/index.php when implementing modularity techniques?

Currently, I am diving into learning how to create a website using PHP and implementing modularity techniques. I recently successfully integrated Bootstrap into a PHP file. However, when I attempted to create a new folder named 'layout' within my ...

Sending a variable to the resize() function in jQuery

Currently, I am working with two specific divs in my project: "#sidebar-wrapper" and ".j1". The height of ".j1" is dynamic as it changes based on its content. My objective is to set this height value to the "#sidebar-wrapper" element. I have attempted to ...

Issue: jQuery Datatable not functioning properly while attempting to populate the table through JavaScript.Explanation: The

I'm currently working on populating a table using JavaScript. However, I've encountered an issue where the table is being populated but it shows "No data available in table". Furthermore, when I try to interact with the data, it disappears. This ...

JavaScript click event not triggering on ASP.NET button

Currently, I am attempting to invoke a C# function from JS without using ajax. One approach I have tried is creating an ASP.NET button that, when clicked, calls the C# function and triggers the click event from JS: In the HTML section: <asp:Button run ...

Retrieving the dynamically selected table row ID using Javascript

Within my application, I am dynamically adding new rows with unique IDs assigned from a loop. When creating a Purchase Order in the view, I am adding these rows to a table. Now, when the value of Select changes, I need to capture the changed row ID and t ...

Tips on adding line breaks after periods that are not at the end of a sentence in HTML text nodes with regular expressions

Looking to craft a regex that can identify all periods not enclosed in quotes and not followed by a '<'. This is for the purpose of converting text into ssml (Speech Synthesis Markup Language). The regex will be utilized to automatically inse ...