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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:14:24+00:00 2026-06-11T00:14:24+00:00

Could You be so kind and help with my jQuery problem? I’m run out

  • 0

Could You be so kind and help with my jQuery problem? I’m run out of power thinking about it.

I have this kind of structure:

<div id="trigger-1">Trigger 1</div>
<div id="trigger-2">Trigger 2</div>
<div id="trigger-3">Trigger 3</div>
 ...
<div id="trigger-n">Trigger n</div>

<div id="content-1">Content 1</div>
<div id="content-2">Content 2</div>
<div id="content-3">Content 3</div>
 ...
<div id="content-n">Content n</div>

All objects are independent, I mean there is no relation parent -> child. What I want to get is fadeing in
DIV marked as a content after run a trigger with the same number in element ID. I know how to get it if I
have for example 5 pairs of DIV, but I can’t create script if I have unlimited pairs of divs.

Of course if content-1 DIV is visible, pressing trigger-2 triggers fadeOut for content-1
and fadeIn for content-2.

Thank You for Your response.

  • 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-11T00:14:25+00:00Added an answer on June 11, 2026 at 12:14 am

    I’d suggest:

    $('div[id^="trigger"]').click(
        function(){
            var num = this.id.match(/\d+/);
            $('div[id^="content-"]').fadeOut();
            $('#content-' + num).fadeIn();
        });​
    

    JS Fiddle demo.

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

Sidebar

Related Questions

I used to have this kind of simple JSON data and I could successfully
I was wondering if anyone could help me out with jQuery file tree (
What kind of data structure could be used for an efficient nearest neighbor search
Suppose you have a subsystem that does some kind of work. It could be
I have a script that loads in a div with images running jQuery Cycle
I have several javascript files that during run-time get combined and minified. This is
I'm seeing a problem using jquery .after to insert a div into an li.
I wonder if someone could be kind enough to explain the function.prototype thingie (thingie!!??)
I was wondering if there's a way I could code some kind of generic
Could anybody be so kind to give me a simple example of reification in

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.