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 5976337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:12:50+00:00 2026-05-22T21:12:50+00:00

I have this code css: div#container{ overflow: hidden; width: 331px; } div#content { position:relative;

  • 0

I have this code

css:

div#container{
overflow: hidden;
width: 331px;
}

div#content {
position:relative;
}

jquery:

$("#left").click(function(){
$("#content").animate({"right": "+=328px"}, "slow");
});

$("#right").click(function(){
$("#content").animate({"right": "-=328px"}, "slow");
});

HTML:

<button id="left"><<</button>
<button id="right">>></button>
<div id="container">
<div id="content">
<table border="0">
<tr>
<td><img src="images/img1.gif"></td>
<td><img src="images/img2.gif"></td>
<td><img src="images/img3.gif"></td>
<td><img src="images/img4.gif"></td>
</tr>
<tr>
<td>Description1</td>
<td>Description2</td>
<td>Description3</td>
<td>Description4</td>
</tr>
</table>

when i click for example prv button 15 times the div move 328px every time!
my question is how to know the last postion that the gallery should stop moving?

thank you

  • 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-05-22T21:12:51+00:00Added an answer on May 22, 2026 at 9:12 pm

    I don’t like using tables for that… Divs make your code much more fluid, and would allow an elegant solution: is(‘:last-child’) on active div

    But since you’re doing it with table, I can think of two ways of doing this

    One is using a counter, then checking it against number of columns of table. If displaying more than one column per step, then it will be total number of columns / visible columns:

    $(function(){
        var position = 1;
    
        $("#left").click(function(){
        var size =  $("#content table").find('tr').first().find('td').size();
    
            if(position < (size / 2) ) {
                $("#content").animate({"right": "+=198px"}, "slow");
                position ++;
            }
        });
    
        $("#right").click(function(){
            if(  position > 1) {
                $("#content").animate({"right": "-=198px"}, "slow");
                 position --;
            }
        });
    });
    

    Fiddle: http://jsfiddle.net/9sYWK/5/

    The other solution consists in calculating how many times #content has moved. You can get it by using $("#content").css('right');. Since you know you always move your div in 328px steps, you can divide it by 328 to get how many times it was clicked

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

Sidebar

Related Questions

I have this code: $(div[id^='intCell']).mouseover(function() { $(this).css({ border:,1px solid #ff097c}); }).mouseout(function() { $(this).css({border:,1px solid
I have this code <html> <head> <style type=text/css> .frame {width: 50em; border: 1px solid
I have this code: var originalBorder = container.css("border"); container.hover(function(event) { event.stopPropagation(); $(this).css("border", "1px solid
I have the following css code .container { width:800px; background-color:yellow; margin:auto; display:table; } .cell
I have the following code in my page: <div id=data_body_container style=overflow: auto; width: 880px;
i have this CSS code: h1 { font-size:22px; color:#341C12; font-weight:normal; font-style:italic; } .h1color h1{
i have this code: $('.access a').toggle(function() { $('link').attr('href', 'styles/accessstyles.css'); $('body').css('font-size', '16px'); }, function() {
I have this background, the css code is: body { background: #FFF url('images/bg.png') no-repeat
I have the following CSS code .editable:before { content: url(../images/icons/icon1.png); padding-right:5px; } this is
I have this code in jQuery, that I want to reimplement with the prototype

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.