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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:44:47+00:00 2026-05-24T12:44:47+00:00

On page load, the javascript would make the menu button active. $(‘#menu ul li.menuItem:eq(1)’).addClass(‘act’).siblings().addClass(‘inact’);

  • 0

On page load, the javascript would make the menu button active.

    $('#menu ul li.menuItem:eq(1)').addClass('act').siblings().addClass('inact');

but the image on the gallery does not slide to the corresponding menu button. The gallery always starts with the first image. What can i add to it so that any menu button that i set as active on page load, whether it be (eq(1), eq(2), eq3)..), can have the correct image to show up

the javascript file is below

    $(document).ready(function(){
var totWidth=0;
var positions = new Array();

$('#slides .slide').each(function(i){
    /* Loop through all the slides and store their accumulative widths in totWidth */
    positions[i]= totWidth;
    totWidth += $(this).width();

    /* The positions array contains each slide's commulutative offset from the left part of the container */

    if(!$(this).width())
    {
        alert("Please, fill in width & height for all your images!");
        return false;
    }
});

$('#slides').width(totWidth);

/* Change the cotnainer div's width to the exact width of all the slides combined */


$('#menu ul li a').click(function(e){

    /* On a thumbnail click */
    $('li.menuItem').removeClass('act').addClass('inact');
    $(this).parent().addClass('act');

    var pos = $(this).parent().prevAll('.menuItem').length;

    $('#slides').stop().animate({marginLeft:-positions[pos]+'px'},450);
    /* Start the sliding animation */

    e.preventDefault();
    /* Prevent the default action of the link */

});
  • 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-24T12:44:48+00:00Added an answer on May 24, 2026 at 12:44 pm
    $(window).load(function(){
        $('#menu ul li.menuItem:eq(1)').addClass('act').siblings().addClass('inact');
        $('#menu ul li.menuItem:eq(1) a').trigger('click'); // this will trigger an click at page load  
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wish to load some additional data from javascript in an HTML page. The
I am using an JavaScript (and AJAX) to dynamically load a PHP page into
I'm having some trouble figuring out how to make the page load architecture of
I need to make a div act like an .net button. So i figured
Upon page load I want to move the cursor to a particular field. No
Is Page.Load the earliest point in the Page.Load life cycle to add Response.AppendHeader?
During an ASP.NET page load I'm opening and closing multiple System.Data.SqlClient.SqlConnections inside multiple controls
I'm currently trying to figure a way to make a website load up and
I have an iframe that loads a page that I would like to disable
I have an iframe that loads a page that I would like to disable

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.