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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:40:50+00:00 2026-06-02T03:40:50+00:00

I have multiple products on the page all being pulled in through database. Under

  • 0

I have multiple products on the page all being pulled in through database.
Under each I have a comment box that I want to show and hide by clicking the comment button.

My Javascript:

$(document).ready(function(){

    $("#product-box div#product-comment-box").hide();
    //$("#product-box div.comment").show();

$("#product-box div.comment").click(function(){
    $("li div#product-comment-box").toggle();
}); 

My HTML of a Product Area:

<li><div id="product-box">
    <div id="product-image"><a href="#"><img src="images/image_2.jpg"></a></div>
    <div id="product-controls">
        <a href="#"><div id="button" class="more"><p>More</p></div></a>
        <a href="#"><div id="button" class="add"><p>Add</p></div></a>
        <div id="button" class="comment"><p>Comment</p></div>
        <a href="#"><div id="button" class="like"><p>Like</p></div></a>
    </div>
    <p>Product Name</p>
    <div id="product-comment-box">Comment</div>
    </div></li>

But this is managing to toggle all comment boxes on every product, how do I separate these the best? I tried using next and nextAll, but with no luck.

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-06-02T03:40:51+00:00Added an answer on June 2, 2026 at 3:40 am

    You must use this to reference the current comment. Remember what the selector is doing, getting everything in DOM that matches.

    $("#product-box div.comment").click(function(){
        $(this).closest('li').find('div#product-comment-box').toggle();
    }); 
    

    Although selecting by id does not seem like a good idea. Try giving that div a class and selecting by that instead.

    //Change
    <div id="product-comment-box">Comment</div>
    
    //To
    <div class="product-comment-box">Comment</div>  
    
    //then select using class instead.
    $("#product-box div.comment").click(function(){
        $(this).closest('li').find('div.product-comment-box').toggle();
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website that contains many different pages of products and each page
I got a page of Products. Some products have multiple images (colors). I want
so i have a page of products, and for each one i want to
I want to have multiple Facebook Like Buttons on a single page, all pointing
I have multiple forms on a page where each form will add individual item
I currently have a table listing all of the products that are in the
I have this web page I'm developing that displays multiple images of one product
I have a page with multiple forms, however all forms need to take the
i have this facebook page: LINK And i want to implement multiple facebook like
I have multiple select boxes on the page all of which share the same

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.