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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:00:44+00:00 2026-06-05T03:00:44+00:00

So I am trying to read some jQuery that was written by my organization

  • 0

So I am trying to read some jQuery that was written by my organization some years ago. I’m not very proficient with jQuery (but I’m okish with Javascript). I’m trying to prevent the slide from rotating to the next slide if a user hovers over it.

Here’s the first part of the code, I think all it is determining is where and how the slide should be appearing. I think it also says that the slide will switch every 7 seconds.

var current_slide_index = 0; //The index of the slide being displayed;
var timer; //the timer counting the delay to the transition
var time_delay = 7000;

    $(document).ready( function() {



        $('.pane:first').addClass('current');

        if (!$.support.opacity) $('.panes .pane').not('.current').hide();

        $('.tabs a').click( function(e) {
            e.preventDefault();

            var triggers = $('.tabs a');
            current_slide_index = triggers.index($(this));

            showSlide();

            });

        });


function showSlide() //Show the slide indicated by current_slide_index
{
    var triggers = $('.tabs a');
    triggers.removeClass('current').eq(current_slide_index).addClass('current');
            var old_slide = $('.panes .pane.current');

            if (!$.support.opacity) {
                old_slide.children().fadeOut(500, function() {
                    old_slide.removeClass('current').hide();
                    $('.panes .pane').eq(current_slide_index).addClass('current').show().children().fadeIn(300);
                    });
            } else {
                old_slide.removeClass('current').fadeOut(500, function() {
                    $('.panes .pane').eq(current_slide_index).addClass('current').fadeIn(300);
                    });
                }

    clearTimeout(timer);
    timer = setTimeout('rotateSlide()',time_delay);

}

I believe this is the section I have to stop – can I do it by setting some sort of conditional that determines whether or not I am hovering over the slide in question? This is where my lack of jQuery knowledge hurts me – I haven’t the foggiest how to how to stop the slider.

function rotateSlide() //move the slide to the next one
{
        //calculate the next index
        var triggers = $('.tabs a');
        //wrap to index zero if necessary
        current_slide_index = (current_slide_index + 1) % triggers.length;

        //Now show the new slide
        showSlide();

}


timer = setTimeout('rotateSlide()',time_delay);

So my questions are, can anyone interpret this code for me in a clearer manner, and is there a way to prevent the slider from sliding if you hover over it?

From what I can tell, I could just select #slider and use something like (this is pseudocode)

if ($("slider").hover) {
blah blah blah thing that prevents slide from rotating
}
else {
code that allows rotating
}
  • 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-05T03:00:45+00:00Added an answer on June 5, 2026 at 3:00 am

    Your understanding of the code is quite accurate. In order to implement the feature you want, I would do a couple of things. First, move the timer code into a pair of functions like this:

    function holdThisSlide() {
      clearTimeout(timer);
    }
    
    function showNextSlideIn(delay) {
      delay = delay || time_delay;
      holdThisSlide();
      timer = setTimeout('rotateSlide()',delay);
    }
    

    Next, put the call to showNextSlideIn() at the bottom of showSlide, where you just removed the clearTimeout/setTimeout lines.

    Finally, add the behaviour for hovering, above your function definitions:

    $(".panes .pane").hover(
      function() { holdThisSlide(); },
      function() { showNextSlideIn(); }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read some settings from php.ini using zend. The API that
I'm trying to read some OpenGL tutorials on the net. the problem is that
I've got a Rails 3.2.1 app that I'm trying to include some jquery in.
I'm new to jQuery. I've searched and found some results that might work, but
I'm trying to read up on the jQuery plugin jqGrid but I'm running short
I'm trying to do some cross domain stuff with YQL and Jquery but i'm
I am trying to read some XML code from a website, and am having
I am trying to read some smps files with python, and found a fortran
I am trying to read some info from a text file by using windows
I am trying to read some data from a python module from a web.

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.