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

  • Home
  • SEARCH
  • 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 8345967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:51:26+00:00 2026-06-09T06:51:26+00:00

With the following function, I can animate a div to the left, but the

  • 0

With the following function, I can animate a div to the left, but the problem is that, the div goes out of the screen area. Is there anyway that I can keep the #mydiv to go to the left within the #container only? If #mydiv is already on the left side, then it should just do nothing.

 $('.left').click(function() {
        $('#myDiv').animate({
            left: '-=30'
            }, 400, function() {
            // callBack
    });

HTML:

<div id="container">
        <a class="left" href="#">Left</a>
    </div>
  • 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-09T06:51:28+00:00Added an answer on June 9, 2026 at 6:51 am

    in order to obtain this you need to verify that the div you want to move is positioned at least 30px from the left side of you #container.

    $('.left').click(function() {
    if (parseInt($('#myDiv').css('left')) >= 30) {     
        $('#myDiv').animate({
            left: '-=30'
            }, 400, function() {
            // callBack
        });
    
         }
     });
    

    example : http://jsfiddle.net/X2TdJ/1/

    If your #container will be positioned to the left of you body marginLeft will not stop and go outside of your #container div.

    example here: http://jsfiddle.net/DAEsX/1/

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

Sidebar

Related Questions

I know the following function can be used to do some pre-save processing. But,
I have the following snippet of code that loops through the jQuery animate function
I have the following jQuery code-- $('div#mid_number_of_mail').mouseover(function () { setTimeout(function () { $('div.element_popup' ,this).stop().animate({
I'm using the following javascript to animate a div, but the div isn't animating...
I have the following jQuery code: $content.each(function(i) { $body = $(this); $(this).find('div.field-content') .animate( {
How can the following function be implemented in various languages? Calculate the (x,y) point
Let's consider the following scenario: a function which can generate code colors from white
I have the following function - it works fine in Firefox: How I can
can someone help with this? I need the following function to do this... $x
Can anyone describe the following php function: function get_setting_value($settings_array, $setting_name, $default_value = ) {

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.