Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7746769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:21:50+00:00 2026-06-01T10:21:50+00:00

I am using the code to add margin to a div on click. It

  • 0

I am using the code to add margin to a div on click. It works perfectly, but I want to make it “animate” when it is adding margin for a sliding effect. How would I use .animate() to accomplish this?

<script type='text/javascript'>
$(document).ready(function () {
    $('.menub').click(function() {
        if ($('.content').css('margin-left') == '300px')
        {
            $('.content').css('margin-left', '0px');
        }
        else {
            $('.content').css('margin-left', '300px');
        }
    });
    $('.navigation a li').click(function() {
        $('.content').css('margin-left', '0px');
    });
});
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:21:51+00:00Added an answer on June 1, 2026 at 10:21 am

    Do this:

    ​$('.content').animate({marginLeft: 300}, 1000);​​​​​
    

    where 300 is the left margin width and 1000 is the number of milliseconds to animate. Apply same logic to do the reverse animation. See http://api.jquery.com/animate/ for more info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following code for add button with image on tool bar, but
I am using this code snippet to add KeyDown event handler to any element
I'm using the following code to add separators between my menu items: #navigation_center li:before
I created a rotating cube using the below code and add bitmaps as sides
I am developing a site to add events to a Google Calendar using code
I have added a UIScrollVIew using IB. Then using the following code i add
I am new to iPhone development. I am using the below code to add
Using the code below (from a console app I've cobbled together), I add seven
I'm using this code: Dim cListItems As New System.Collections.Generic.List(Of Combobox_values) cListItems.Add(New Combobox_values(One, 1)) cListItems.Add(New
I have a div $(#organizer_listings_container) initially centered using CSS margin: 0 auto; which uses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.