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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:47:43+00:00 2026-06-14T11:47:43+00:00

I am using the function toggle with divs that are dynamically inserted, only instead

  • 0

I am using the function toggle with divs that are dynamically inserted, only instead of running only the specific element, the toggle execute all div content.

HTML:

<div style="text-align: center;">
    <p class="button-style add-comment"><a href="#">Add Comment</a></p>
    <div class="insert-comment" style="display: none;">
        <textarea rows="8" cols="50" class="insert-comment-text"></textarea>
    </div>
</div>

jQuery:

$(document).on('click', '.add-comment', function(e){
    $(".insert-comment").toggle(); 
});

How do I open just a specific div and not all?

  • 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-14T11:47:44+00:00Added an answer on June 14, 2026 at 11:47 am

    Perhaps this is what you need?

    $(this).next(".insert-comment").toggle();
    

    In fact, if all elements with class add-comment are always followed by divs that need toggling, the second selector is just slowing you down:

    $(document).on('click', '.add-comment', function(e){
        $(this).next().toggle();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of divs that I am expanding/retracting individually using .toggle and
I'm using the function below that toggles divs, and with it, any one of
I'm trying to hide some divs that I have created dynamically using the .hide()
I'm using the jQuery toggle function to change some characters of an text input.
I've a code to sort table using Jquery.I use toggle function to alternate clicks,and
In using a function, I wish to ensure that the type of the variables
i am using togglefullscreen() function to ofc toggle between window mode & full screen
I have a TD that contains two divs. The first div contains text and
I toggle a div using something like this - <input type=radio name=myRadio value=myDiv_1 />MyDiv
I am using .toggle to expand/retract individual divs with the click of an anchor

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.