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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:19:33+00:00 2026-05-28T02:19:33+00:00

This was my first go at writing some jQuery code completely from scratch, so

  • 0

This was my first go at writing some jQuery code completely from scratch, so aside from the fact that I went wrong somewhere, I’m also not sure if this is the best way to do what I’m trying to do. Here goes!

I’m using jQuery Swipe.js to control a slider on a mobile site. The slider contains 3 divs. I also have some left/right arrow buttons that a user can click that calls the Swipe function.

I want to hide/show some divs when the swipe action is called, depending on what is currently in the viewport. I’ve tried to do this using a simple variable, i, which is added/subtracted from depending on the current page the user is viewing.

The original script to call the swipe.js function was simply var slider = new Swipe(document.getElementById('slider'));

The script code that I wrote is this: //EDIT: Updated after reviewing the Swipe documentation

var slider = new Swipe(document.getElementById('slider'), {
      callback: function() {

        var pageNumber = slider.getPos();
        if (pageNumber = 0) {
            $(".leftArrow").css("display", "none");
            $("footer#about").css("display", "none");       
            $("footer#adFooter").css("display", "none");
        }

        else if (pageNumber = 1) {
            $(".leftArrow").css("display", "inline");
            $("footer#adFooter").css("display", "inline");          
            $("footer#about").css("display", "none");

        }

        else if (pageNumber = 2) {
            $("footer#adFooter").css("display", "none");        
            $("footer#about").css("display", "inline");
        }     
    }
});

The HTML code is this:

<a href='#' onclick='slider.prev(); return false;'><img class="leftArrow" src="img/arrow_right.png" alt="Left Nav Arrow"/></a>
<a href='#' style="" onclick='slider.next(); return false;'><img class="rightArrow" src="img/arrow_right.png" alt="Right Nav Arrow"/></a>

I can’t exactly see where I’ve gone wrong here, but evidently the whole thing isn’t working. Thoughts?

  • 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-28T02:19:34+00:00Added an answer on May 28, 2026 at 2:19 am

    You don’t say what problems you are having, but one problem is clear. i can be both -1 and 3. Change your two if statements to say i>0 and i<2 and don’t include the = as you do now.

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

Sidebar

Related Questions

I an writing some JQuery to split some html code at a specific height.
I'm having some difficulty with writing some jQuery code. What i'm trying to do
I'm now writing my first jQuery Plugin and i found this blog post about
i'm busy writing my very first jquery plugin and i ran into some problems.
Disclaimer: This is my first time writing unit tests...be gentle! :) I am trying
This is my first question :). Im writing a little twitter app in PHP
I've followed this tutorial: http://anandhansubbiah.com/blog/writing-your-first-android-application/ , but no matter what I do, and what
I'm writing an application using DDD techniques. This is my first attempt at a
Saw this piece of code in a Ruby on Rails book. This first one
For example, i associate following function with some element $('table#users tbody tr:first #save').click(function(){ $(this).closest('tr').remove();

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.