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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:15:51+00:00 2026-06-03T14:15:51+00:00

There are two div sections with the same class and also has same ul

  • 0

There are two div sections with the same class and also has same ul and li and a.

I have two jQuery click events in my code. When I click Google both of the jQuery click events fire. But I do not want both to do so, only one. How do I achieve this?

For example, if Google gets clicked I want only that jQuery click event to do something, not the other one. These are the DOM element I am working with:

<div class = "abc">
 <ul>  
  <li class="year_"><a href="www.google.com">google</a></li>
 </ul>
</div>
<div class ="abc">
 <ul>
  <li><a href="www.yahoo.com>yahoo</a></li>
 </ul>
</div>

The href might change so I cannot base my selector on that. The code that I have follows.

$( 'div.abc ul li[class^="year_"]  a' ).click( function(){
    //do something
});

$( 'div.abc ul li a' ).click( function(){
    //do something
});
  • 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-03T14:15:52+00:00Added an answer on June 3, 2026 at 2:15 pm

    You could do a conditional statement, finding the li with the “year_” class:

    $( 'div.abc ul li a' ).click( function(){
        if ($(this).parents('li').is('[class^="year_"]')){
            //do something
        } else {
            //do something else
        }
    });
    

    See jsfiddle.

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

Sidebar

Related Questions

My page has two 'tabbed' navigation sections. Both independent of one-another, but resulting in
Is there a way to overlay/overlap two or more images using one div only?
I have these div blocks called columns where each column div contains separate two
one <div id=2 class=h>two</div> <div id=3 class=h>three</div> <div id=4 class=h>4</div> <div id=5 class=h>5</div> When
If i have the following markup; <div id=container> <div id=box> <div id='sameHeight'>One<br>two<br>three</div> <div id='sameHeight'>four</div>
I have read a document that they say: In java there two types of
There are two ways to overload operators for a C++ class: Inside class class
Ok, so I have several sections to a webpage that I am making. There's
I have two DIV-elements, which are assigned an array called stack using data() .
I have used two div tags in my blog to wrap programming codes. The

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.