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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:11:44+00:00 2026-06-16T02:11:44+00:00

ASP.Net, 2.0 VS2005, .Net 2.0 jQuery 1.8.3, jQuery UI 1.9.2 I have two panels

  • 0

ASP.Net, 2.0 VS2005, .Net 2.0 jQuery 1.8.3, jQuery UI 1.9.2

I have two panels (more will come later on) on my form that can be open or closed at the users request.

i am using the jQuery ‘.slideToggle’ method.

This is my markup

<div class="trigger0">Collapsible Header 1 - Click to toggle</div>
            <div class="panel0">
                content 1
            </div>
           <div class="trigger1">Collapsible Header 2 - Click to toggle</div>
            <div class="panel1">
                content 2
            </div>

The following works fine

$(document).ready(function() {
        $(".trigger0").click(function(){
            $(".panel0").slideToggle("medium");
        });
        $(".trigger1").click(function() {
            $('.panel1').slideToggle("medium");
        });
    });      

but this doesn’t

$(document).ready(function() {
        for (var vReportSectionCount = 0; vReportSectionCount < 2; vReportSectionCount++)
        {
            $(".trigger" + vReportSectionCount).click(function(){
                $(".panel" + vReportSectionCount).slideToggle("medium");
            });
        }
    });

As i dont yet know how many panels will finally exist i dont want to have to write a new line for every panel. Can someone explain to me why and propose a better solution?

  • 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-16T02:11:46+00:00Added an answer on June 16, 2026 at 2:11 am

    Could this be something you’re looking for? This lets you name the classes as classes and not ID’s

    HTML

    <div class="trigger">Collapsible Header 1 - Click to toggle</div>
    <div class="panel">
        content 1
    </div>
    
    <div class="trigger">Collapsible Header 2 - Click to toggle</div>
    <div class="panel">
        content 2
    </div>
    

    Javascript

    $(document).ready(function() {
        $(".trigger").click(function(){
            $(this).next(".panel").slideToggle("medium");
        });
    });
    

    You can see a demo here: http://jsfiddle.net/LkTf8/1/

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

Sidebar

Related Questions

I have an VS2005 ASP.Net page with a repeater on it of Customers. The
I am using Telerik asp.net mvc extensions. I have an issue that happens only
I have some internal-facing ASP.NET web services that have had numerous API additions over
I am using ASP.NET C# on VS2005. I have a GridView table with a
VS2005, ASP.NET, C#, IIS6 Hello friends, I have a master page divided into three
I have an puzzling problem. I have a new ASP.NET web application in VS2005
I am using C# ASP.NET on VS2005. I have a gridview table but it
I am using VS2005 C# ASP.NET. I have a .aspx page with a script
How have you guys handled working with jQuery includes <script type=text/javascript src=jquery.js></script> in Asp.Net
We've got an ASP.Net 2.0 (VS2005) application that works fine locally, but sometimes loses

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.