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

  • Home
  • SEARCH
  • 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 6832409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:51:18+00:00 2026-05-26T22:51:18+00:00

I’m just starting to use jQuery and I’m having some trouble with something I

  • 0

I’m just starting to use jQuery and I’m having some trouble with something I can easily do in other languages.

I have a list of elements and each element contains a list of information.
My problem comes from the fact that I can’t use jQuery to slideDown or slideUp information about these elements because I can’t get a unique identifier for each one.

$(function()
{
    classe = "#afficheDetails" + 0;
    $(classe).click(function()
    {
        affiche = "#detailsFeuille" + 0;
        if($(affiche).css("display") == "block")
        {
            $(affiche).slideUp();
        }
        else 
        {
            $(affiche).slideDown();
        }
    });
});

update :

Also, I’m in a for loop, so I have not always the same number of elements to display…

<p id='afficheDetails<?php echo $i;?>'>to display info, click here</p>

            <table id='detailsFeuille<?php echo $i;?>'>
                <tr>
                    ...
                </tr>

                <tr>
                    ...
                </tr>
</table>

This kind of thing is actually working but as you can see I’m not adding the indice dynamically, it’s all manual. And my list of elem can contain a lot of elements.

I tried to create a not-anonymous function but every time I call it, I get an error : myFunction is not defined.

Could you help me?

Thx!

  • 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-26T22:51:18+00:00Added an answer on May 26, 2026 at 10:51 pm

    By index

    // Select all elements that start with "afficheDetails"
    $("[id^='afficheDetails']").click(function(){
        var index = $("[class^='afficheDetails'").index(this); // Index of the element
        $("[id^='detailsFeuille']").eq(index).slideToggle();
    });
    

    Check this demo: http://jsfiddle.net/fRyjV/1/

    By ID

    $("[id^='afficheDetails']").click(function(){
        // Replace the first part of the ID with nothing to get the integer.
        var id = this.id.replace("afficheDetails", "");
        $("#detailsFeuille" + id).slideToggle();
    });
    

    Check this demo http://jsfiddle.net/fRyjV/

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have some data like this: 1 2 3 4 5 9 2 6
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

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.