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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:52:07+00:00 2026-05-22T02:52:07+00:00

My anchor tag is not working here is my code : $(‘.tree div’).click(function(){ var

  • 0

My anchor tag is not working

here is my code :

   $('.tree div').click(function(){
                    var o = $(this);
                    o.children('div').slideToggle();
                    o.filter(".parent").toggleClass("expand");
                    return false;

                });

my html code is :

 <div class="tree">
            <div class="parent">
                Parent
                <div class="parent">
                    Parent 1
                    <div>
                        <a href="http://google.com">Childe 2.1</a>
                    </div>
                    <div>
                        Childe 2.2
                    </div>
                </div>
                <div class="parent">
                    Parent 2 
                    <div>
                        one 3.1
                    </div>
                    <div>
                        one 3.2
                    </div>
                </div>
            </div>
            <div class="parent">
                Parent
                <div class="parent">
                    parent 1
                    <div>
                        Childe 2.1
                    </div>
                    <div>
                        Childe 2.2
                    </div>
                </div>
                <div class="parent">
                    parent 2
                    <div>
                        Childe 2.1
                    </div>
                    <div>
                        Childe 2.2
                    </div>
                </div>
            </div>
        </div>

but when i click on Childe 2.1 it doesn’t open google.com

Please help me.

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-22T02:52:08+00:00Added an answer on May 22, 2026 at 2:52 am

    I think this is what you want. The e.stopPropagation() is what I added.

    $('.tree div').click(function(e){
                    var o = $(this);
                    o.children('div').slideToggle();
                    o.filter(".parent").toggleClass("expand");
                    e.stopPropagation();
                });
    
    • Note I also added e as an argument to the function function(e).

    • Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.

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

Sidebar

Related Questions

How do I set the text of an anchor tag in javascript? This does
I have an anchor tag on my page that toggles between active and cancelled
Here is what I want to do. Use this HTML line and have the
I have an anchor tag in my application that has the sole purpose of
I've an image that is wrapped in an anchor tag that, through jQuery, triggers
Below is my code present in my application : <input id=input value=Testing /> <a
I'm working on a small Python script to clean up HTML documents. It works
I am using Spring MVC for an application I am building. Everything is working
I've difficulties to set up css rules of tags containing text inside li tag.
I had in my mind that it would not be hard to add an

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.