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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:33:45+00:00 2026-06-10T11:33:45+00:00

Here is my html code: <div id=bibletree> <p id=gen>Genesis</p> <p class=gen>01</p> <p class=gen>02</p> <p

  • 0

Here is my html code:

<div id="bibletree">
  <p id="gen">Genesis</p>
  <p class="gen">01</p>
  <p class="gen">02</p>
  <p class="gen">03</p>
  <p class="gen">04</p>
  <p id="exo">Exodus</p>
  <p class="exo">01</p>
  <p class="exo">02</p>
  <p class="exo">03</p>
  <p class="exo">04</p>
  <p id="lev">Leviticus</p>
  <p class="lev">01</p>
  <p class="lev">02</p>
  <p class="lev">03</p>
  <p class="lev">04</p>     
</div>

Javascript:

$("#bibletree p").click(function() {
  $(".gen").slideToggle(400)
});

As you can see, I am matching any and all <p> tags inside the bibletree <div>. I want to know how to only toggle those <p> that have the class that is the same as id of the clicked element. So, instead of toggling .gen it will toggle .[id of <p> that was clicked]. What I am asking for is reminiscent of regex references. Any ideas?

  • 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-10T11:33:46+00:00Added an answer on June 10, 2026 at 11:33 am

    jsBin demo

    $("#bibletree p[id]").click(function() {
      $("."+this.id).slideToggle(400);
    });
    

    EDIT:
    if you want to remove all (unnecessary?) classes you could do:

    $("#bibletree p[id]").click(function() {
      $(this).nextUntil('p[id]').slideToggle(400);
    });
    

    jsBin demo

    <div id="bibletree">
      <p id="title">Genesis</p>
      <p>01</p>
      <p>02</p>
      <p>03</p>
      <p>04</p>
      <p id="title">Exodus</p>
      <p>01</p>
      <p>02</p>
      <p>03</p>
      <p>04</p>
      <p id="title">Leviticus</p>
      <p>01</p>
      <p>02</p>
      <p>03</p>
      <p>04</p>     
    </div>
    

    CSS:

    #bibletree p{
      display:none;
    }
    #title{
     display:block;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question 1 Here is the HTML code. <div class=preferredContact paragraph>ph:<span preferredcontact=40>(02) 9540 9959</span></div> I
Here is HTML code: <div class=row> <span class=item><a href=#>A</a></span> <span class=item><a href=#>B</a></span> <span class=item><a
Here is my HTML code: <div id=playlist_item> <ul class=link id=link> <div class=style><input type=checkbox class=styled>
Here is my HTML code <div class=column> <div class=open></div> <div class=close></div> <div class=content> This
first here is my html code: <div class=outter> <div class=item></div> <div class=item></div> <div class=item></div>
here is the html code : <div id=popup class=popup_block > <img src=images/PUB-histRIRE.jpg alt=popup />
Here is my HTML code <span class=xxt style=>Hide Me</span> <div><br/></div> <div></div> <span style=> <table>
Here is my html code: <div id=notes> <table class=noborder> <tr><th class=noborder><span>notes</span></th></tr> <tr><td> <p id=notes_p>
Here is the DEMO HTML CODE as <div id=me></div> <a id=ok href=>OK</a> jquery code:
I want to make some design tweaks. Here is the code for html: <div

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.