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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:37:47+00:00 2026-05-24T09:37:47+00:00

Possible Duplicate: Use same div to toggle different parts of the page Hello I

  • 0

Possible Duplicate:
Use same div to toggle different parts of the page

Hello I have the following code:

Javascript/jQuery:

 $(document).ready(function() {
  $(this).find("a").click(function() {
   $(this).find("div").toggle();
  });
});

Html code printed with a for loop:

<div>
<a class="clickMe">Toggle my text</a>
<br />
<div class="textBox"> - This text will be toggled</div>
</div>

<div>
  <a class="clickMe">Toggle my text</a>
  <br />
  <div class="textBox"> - This text will be toggled 2</div>
</div>

<div>
  <a class="clickMe">Toggle my text</a>
  <br />
  <div class="textBox"> - This text will be toggled 3</div>
</div>

I would like to be able:

  1. When the page loads I want the to be hidden and toggle on click.
  2. Using the same classes for <a class="clickMe"> and <div class="textBox"> to be able to toggle or hide the correct/equivalent <div> element.

jsFiddle code:

http://jsfiddle.net/A7Sm4/8/

Thanks

  • 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-24T09:37:47+00:00Added an answer on May 24, 2026 at 9:37 am

    This updated jsFiddle will work. Basically changing the first find into just a regular selector, and then going to the parent of the anchor to find the child divs, and toggling them.

    One of many ways to accomplish this task though.

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

Sidebar

Related Questions

Possible Duplicate: Are @property(nonatomic)ivar @property(nonatomic,assign)ivar the same or different? i have seen in many
Possible Duplicate: How to use javascript variables in jquery selectors This works $('input[name=nickname]').css(...); Now
Possible Duplicate: In jquery: Use attr(“class”) value as a selector? I have fields with
Possible Duplicate: When do you use the “this” keyword? If I have the following
Possible Duplicate: How can I use a string with the same name of an
Possible Duplicate: When to Use Double or Single Quotes in JavaScript Are there differences
Possible Duplicate: Home button listener I use below code to listener home button pressed:
Possible Duplicate: Where would I use a bitwise operator in JavaScript? In c/c++ bitwise
Possible Duplicate: Hibernate: different object with the same identifier value was already associated with
Possible Duplicate: When to Use Static Classes in C# I will write code 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.