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

The Archive Base Latest Questions

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

I am trying to approve the slide show I use below, here is the

  • 0

I am trying to approve the slide show I use below,

here is the html,

<!--slide-->
<div id="slide">

    <ul class="slide">
        <li><img src="contents/slide-1.jpg" alt="slide 1"/></li>
        <li><img src="contents/slide-2.jpg" alt="slide 2"/></li>
        <li><img src="contents/slide-3.jpg" alt="slide 3"/></li>
    </ul>

</div>
<!--slide-->

becos I might have a number of slide sets I want to loop them, or I might change the id name from time to time, so I am thinking to run the functions in this method rather than changing the code in the function everytime for different situation,

run_slide('#slide');

so I can do a multiple calls from the same functions,

run_slide('#slide-2');

run_slide('#slide-3');

below is the function, the first part of the function runs ok, but the second part of it isn’t ok when I want to pass the id through interval – setInterval('loop_slide('+target_slide+')',5000);

I have this error message on my Firefox browser which I don’t quite understand it,

illegal character [Break On This
Error] loop_slide(#slide)

function run_slide(target_slide) {

    //add a class the the first element
    $('li:first-child',target_slide).addClass('active');

    //Set the opacity of all images to 0
    $('.slide li').css({opacity: 0.0});

    //Get the first image and display it (set it to full opacity)
    $('.slide li:first-child').css({opacity: 1.0});

    //Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
    setInterval('loop_slide('+target_slide+')',5000);
}

function loop_slide(target_slide) {

    //var target_slide = $('#slide');

    //if no IMGs have the show class, grab the first image
    var current = ($('.slide li.active')?  $('.slide li.active') : $('.slide li:first-child'));

    //Get next image, if it reached the end of the slideshow, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('.slide li:first-child') :current.next()) : $('.slide li:first-child')); 

    //Set the fade in effect for the next image, show class has higher z-index
    current.addClass('last-active');
    next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, 1000, function(){
        current.animate({opacity: 0.0}, 1000).removeClass('active last-active');

        $('.caption p',target_slide).html(caption_description);
    });

}

how can I fix it? why can’t I pass the id into the second function but I can in the first function?

many thanks.

  • 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-19T04:08:34+00:00Added an answer on May 19, 2026 at 4:08 am
    setInterval('loop_slide('+target_slide+')',5000);
    

    seems to be the problem, as the variable you pass is parsed to loop_slide(#slide) instead of loop_slide(‘#slide’) hence eval fails.

    simple solution:

    setInterval('loop_slide(\''+target_slide+'\')',5000);
    

    besides that: if you are creating this slider for learning purpose it could be a good idea to write it as a jquery plugin – see http://docs.jquery.com/Plugins/Authoring.

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

Sidebar

Related Questions

im trying to hide the parent div that contains the clicked link: <div class=user
Trying to copy the msdn refernce here doesn't work and gives an error I
i have the following code trying to save the contents of a JTextPane as
We are trying to create a proxy class that would serve the WCF service
I'm trying to implement email confirmation using Pyramid framework. Here's the code that confirms
I am basically trying to use the PAY call of Adaptive Payments to programmatically
I am trying to submit open graph action. Below is the text that I
I'm trying to programatically approve/reject workflows in SharePoint. I can successfully do this, but
I am trying to get the actionlink to align right for this code. <div
I am trying to get this form to submit correctly. Here's what I have

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.