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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:07:34+00:00 2026-06-14T17:07:34+00:00

Am toggling few div’s on my website which are looped using PHP, now what

  • 0

Am toggling few div’s on my website which are looped using PHP, now what the issue is am passing div id, but this will make 10 scripts if am looping 10 articles, any better way to pass an id and open the associated div?

http://jsfiddle.net/NbGSB/

<script>
$('#toggle4').click(function() {
$('.toggle4').slideToggle('fast');
    return false;
});
</script>
<a href="#" id="toggle4">Slide Toggle</a><br /><br />
<div class="toggle4" style="display:none; background-color:#4CF;width:100px;height:200px;"></div>

Now what if am having multiple div’s? do I need to pass the id always and loop the script too or is there any better way? sorry but am not good with jQuery

  • 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-14T17:07:35+00:00Added an answer on June 14, 2026 at 5:07 pm

    Yes, just give to your articles one class, like a “arcticle-toggle”, then slide div after two br-tags:
    HTML:

    <a href="#" class="article-toggle">Slide Toggle 1</a><br /><br />
    <div style="display:none; background-color:#4CF;width:100px;height:200px;"></div>
    
    <a href="#" class="article-toggle">Slide Toggle 2</a><br /><br />
    <div style="display:none; background-color:#8CF;width:100px;height:200px;"></div>
    

    ​JS:

    <script>
     $('.article-toggle').click(function() {
      $(this).next().next().next().slideToggle('fast');
     return false;
    }
    </script>
    

    Fiddle.

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

Sidebar

Related Questions

I am toggling a div using jquery. when this div appears on page my
I'm using this script for toggling/accordioning divs on my website: <script type=text/javascript src=https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js></script> <script
i'm trying to make toggling div with only 1 javascript. I tried this, the
Here's JSFiddle Everything's explained there in the fiddle. Here, div is toggling below, but
I've having this weird issue where toggling the visibility of a button seems to
I'm using Unobtrusive Toggling in a view that contains many records (Orders). I've got
I'm trying to create a simple toggling sidebar using jquery, where it expands and
I just want to control a div by toggling a class on click, as
I'm toggling the datasource of an tableview but the indexPath.row throws me an exception
I'm currently toggling a dropdown div menu with the following code: $(function() { function

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.