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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:22:07+00:00 2026-05-24T20:22:07+00:00

I’m not the best programmer, in fact I’m no programmer at all, I can

  • 0

I’m not the best programmer, in fact I’m no programmer at all, I can handle HTML and CSS but anything more advanced is beyond me. I’ve implemented jCapSlide on a website, and it works fine, however, each of the images has to have it’s own attributes, like so:

    <script type="text/javascript">
        $(function() {
            $("#capslide_img_cont").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont2").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont3").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont4").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont5").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont6").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont7").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont8").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont9").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont10").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont11").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont12").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont13").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont14").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont15").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont16").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont17").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont18").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont19").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });
            $("#capslide_img_cont20").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });

        });

    </script>

Obviously this creates a lot of redundant code, therefore loading time (and every little helps), so I’m after info on how to reduce this. I’ve tried this:

    <script type="text/javascript">            $(function() {
            $("#capslide_img_cont","#capslide_img_cont2","#capslide_img_cont3","#capslide_img_cont4","#capslide_img_cont5","#capslide_img_cont6","#capslide_img_cont7","#capslide_img_cont8","#capslide_img_cont9","#capslide_img_cont10","#capslide_img_cont11","#capslide_img_cont12","#capslide_img_cont13","#capslide_img_cont14","#capslide_img_cont15","#capslide_img_cont16","#capslide_img_cont17","#capslide_img_cont18","#capslide_img_cont19","#capslide_img_cont20"").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });

        });

    </script>

And this:

    <script type="text/javascript">
    var allBoxes=new Array("capslide_img_cont","capslide_img_cont2","capslide_img_cont3","capslide_img_cont4","capslide_img_cont5","capslide_img_cont6","capslide_img_cont7","capslide_img_cont8","capslide_img_cont9","capslide_img_cont10","capslide_img_cont11","capslide_img_cont12","capslide_img_cont13","capslide_img_cont14","capslide_img_cont15","capslide_img_cont16","capslide_img_cont17","capslide_img_cont18","capslide_img_cont19","capslide_img_cont20");
        $(function() {
            $("#allBoxes").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
            });

        });

    </script>

Neither of which work. Any suggestions gratefully appreciated!

  • 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-24T20:22:09+00:00Added an answer on May 24, 2026 at 8:22 pm
    $("[id^='capslide_img_cont']").capslide({
                caption_color   : 'white',
                caption_bgcolor : '#005ca7',
                overlay_bgcolor : 'orange',
                border          : '',
                showcaption     : true
        });
    

    This will select all elements with ids that start with “capslide_img_cont”. Here is a link to the jQuery selectors documentation where you can see all the different ways to select objects: http://api.jquery.com/category/selectors/

    Also you were close with your first try but here is the proper implimentation:

    $("#capslide_img_cont, #capslide_img_cont2, #capslide_img_cont3,...")
    

    If you are worried about loading time I would recommend putting all of your “capslide_img_cont” elements into a div with an id, then using a selector like this (assuming the “capslide_img_count” elements are img tags):

    $('#capslide_img_container').find('img').capslide...
    

    This is a fast selector that finds the single element with the ‘capslide_img_container’ id and then finds all the img tags within it, whereas my example of [id^=’capslide_img_cont’] searches every id on the page (a class-based selector also searches the whole page).

    Example HTML:

    <div id="capslide_img_container">
        <img id="capslide_img_cont" src="..." />
        <img id="capslide_img_cont2" src="..." />
        <img id="capslide_img_cont3" src="..." />
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I want to count how many characters a certain string has in PHP, but
In order to apply a triggered animation to all ToolTip s in my app,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a JSP page retrieving data and when single or double quotes are
I want use html5's new tag to play a wav file (currently only supported
I have just tried to save a simple *.rtf file with some websites and

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.