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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:59:27+00:00 2026-06-02T20:59:27+00:00

html: <div class=a> <div class=g></div> <a class=e>Link</a> <div class=g></div> <a class=e>Link</a> </div> I want

  • 0

html:

 <div class="a">

   <div class="g"></div>
   <a class="e">Link</a>

  <div class="g"></div>
   <a class="e">Link</a>

</div>

I want to hide the div with class “g” whenever I click on the link.Only that particular link.Suppose if i clicked on the first link then the first div with class “g” should hide only.Now wat i’ve done is here.

Jquery:

    $('.e').click(function(){
               c();
       });

    function c(){
          $(.g).hide();
      }

but this is hiding all the elements of class “g”.

Both the div with class “g” and link are generated by the users dynamically and i dont know how many the users can generate.

  • 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-02T20:59:29+00:00Added an answer on June 2, 2026 at 8:59 pm

    Currenctly you are calling $('.g').hide() which is selecting all the element with g as the class and hiding them all.

    Instead use prev() to select element which you want to hide

           $('.e').click(function(){
                  jQuery(this).prev().hide();
           });
    

    Demo

    Updated as per comment:

    You can use this code:

    $('.e').click(function(){
                  c(this);
           });
    
    function c(element){
              $(element).prev().hide();
          }
    

    Live Demo

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

Sidebar

Related Questions

Here's the HTML that my browser sees. I want to hide the div.embed element:
So I have some html that looks like the following: <div class='something unknown' id='something_unknown_1'>
Hi I've got something like the following HTML: <div class="container"> <img src="first.png" /> <img
Suppose I have the following html: This a test of <code>some code</code>. <div class='highlight'>
I have a that contains a link with class 'remove-project' that I want to
<div class = a> <div class = a b> text </div> </div> <script> alert($(.a).html());
How to set this.class to do something? Now this.block doesn't work! HTML <div class=container>
Is this html <div class='title centered'>SCE</div> <div class='description'> Magna tristique pulvinar porta montes, scelerisque
This is my code : HTML <div class='father'> <div class='son'>Son</div> </div> CSS .father {
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </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.