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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:45:55+00:00 2026-05-27T21:45:55+00:00

I need to run same effect in multi id’s in the same page What

  • 0

I need to run same effect in multi id’s in the same page
What is the short way to do this:

function showDisc1(){$('#bottomBox1').slideDown();$("#bottomBox1").addClass("open");$("#bottomBox1").removeClass("close");}
function showDisc2(){$('#bottomBox2').slideDown();$("#bottomBox2").addClass("open");$("#bottomBox2").removeClass("close");}
function showDisc3(){$('#bottomBox3').slideDown();$("#bottomBox3").addClass("open");$("#bottomBox3").removeClass("close");}
function showDisc4(){$('#bottomBox4').slideDown();$("#bottomBox4").addClass("open");$("#bottomBox4").removeClass("close");}
...... etc

$(document).ready(function() {
$('#openbottomBox1').click(function(){
if ( $('#bottomBox1').hasClass('close') ) {
showDisc1();
} else if ( $('#bottomBox1').hasClass('open') ) {
hideDisc1();
};});});
.... again!!

HTML:

<div class="bottomBox close">
<div class="wrapper">
<a class="left disc" href="javascript:;" id="openbottomBox1"><div class="left text">View Description</div><div class="sprite right"></div></a> | <a class="itemDetails" href="javascript:;" id="itemDetails1">Details</a>
</div>
<p class="close clear discContent" id="bottomBox1"><a href="javascript:;" class="hideDisc" id="hideDisc1">x</a>
jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.
</p>
</div>
  • 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-27T21:45:55+00:00Added an answer on May 27, 2026 at 9:45 pm

    If you have no other choice but to use IDs as identifiers, use this:

    $(document).ready(function()
    {
        $('#openbottomBox1, #openbottomBox2, #openbottomBox3, #openbottomBox4').click(function()
        {
            var $bottomBox = $('#bottomBox' + this.id.substr(-1));
    
            if ( $bottomBox.hasClass('close') )
            {
                $bottomBox.slideDown().addClass('open').removeClass('close');
            }
            else if ( $bottomBox.hasClass('open') )
            {
                $bottomBox.slideUp().removeClass('open').addClass('close');
            };
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two scripts that often need to be run with the same parameter:
I need to generate a new interface at run-time with all the same members
I need to run a JavaScript function onLoad(), but only do it if the
I need a way to create a collide effect, without the actual collision between
I need to run 3 consecutive queries using the same derived table... I'm using
i need run code that will create a database and populate tables. i am
I need to run a stored procedure from a C# application. I use the
I need to run an equipment audit and to do that I need to
I need to run a Linux CLI command and get its stdout output from
I need to run a RLIKE query on a database mmoved from MySQL to

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.