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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:50:07+00:00 2026-06-03T21:50:07+00:00

I have the following code: <div id=slideshow > <div class=check> <img src=images/slideshow/image01.jpg alt=Slideshow Image

  • 0

I have the following code:

<div id="slideshow" >
    <div class="check">
        <img src="images/slideshow/image01.jpg" alt="Slideshow Image 1" />
    <p>Some paragraph</p>
    </div>    
    <div>
        <img src="images/slideshow/image02.jpg" alt="Slideshow Image 2" />
        <p>Some paragraph</p>
    </div>
    <div>
        <img src="images/slideshow/image03.jpg" alt="Slideshow Image 3" />
        <p>Some paragraph</p>
    </div>
</div>

I found this slideshow method that uses the following code to fade DIVs in and out over each other to create a sort of image slideshow::

function slideSwitch() {

var $active = $('#slideshow DIV.check');

if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

var $next =  $active.next().length ? $active.next()
    : $('#slideshow DIV:first');

$active.addClass('last-active');

$next.delay(2000)
    .css({opacity: 0.0})
    .addClass('check')
    .animate({opacity: 1.0}, 1000, function() {
        $active.removeClass('check last-active');
    });
}

$(function() {setInterval("slideSwitch()", 8000);});

As you can see, it adds the class “check” which fades in the DIV. What I’m trying to do is check with Jquery when the slideSwitch function has added the class “check” to the Div, and then do something. I’ve tried this, but it doesn’t work:

if ($("#slideshow > div:nth-child(2)").hasClass('check')) {
    $("#slideshow > div:nth-child(2)").animate({marginTop: "-50px"}, 5000);
} else {
//Do nothing
} 

It works if I just check for the 1st child or if I just add this (probably because it already has the class defined in the HTML code):

if ($("#slideshow DIV").hasClass... etc

But then the animation starts right away, when what I really want is for it to start right after the 2nd DIV has had the class “check” assigned in JavaScript. Please help!!!!!

  • 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-03T21:50:08+00:00Added an answer on June 3, 2026 at 9:50 pm

    The class is added immediately when called in your code above. Why not include your animation there?

    $next.delay(2000)
        .css({opacity: 0.0})
        .addClass('check')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('check last-active');
            $("#slideshow > div:nth-child(2)").animate({marginTop: "-50px"}, 5000);
    
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code <div class=img> <img src=image/1.jpg class=img_s style=display:none; /> <img src=image/2.jpg class=img_s
I have following PHP code $val=<div id=user.$row['cid']. userid=.$row['cid']. class=innertxt><img src=images/images.jpg width=50 height=50><strong>.$uname.</strong><ul> <li>Email: .$row['cemail'].</li>
i have following code <div class=caption style= position:absolute; margin-top:0px> <img src=caption/img1.png /> </div> <script>
I have the following code: $('<div style=background-image:url(\'/images/a.gif\')></div>').appendTo('body') depending on where I am on a
I have the following code: <div id=object-container> <object data=some-file.swf> <param name=src value=some-file.swf /> </object>
I have the following code: <div style=width:100% align=center> <img src=./platform-logos-big.png alt=Icons of platforms we
I have the following code: <div style=width: 150px> <div style=padding: 5px> <img src=http://xenforomods.info/styles/Silent/xenforo/browser/announcementIcon.png width=50px
I have following code: <div class='parent'> <div class='left-child'></div> <div class=right-child></div> </div> What I want
I have the following code <div class=framepage> <header> <script type=text/javascript> function getBaseUrl() { return
I have the following jQuery code: var shown = $('div.slideshow').find('div.slide:visible'); var next = shown.next();

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.