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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:15:19+00:00 2026-06-16T11:15:19+00:00

Possible Duplicate: jQuery: Target all except ___? I’ve got a script that detects clicks

  • 0

Possible Duplicate:
jQuery: Target all except ___?

I’ve got a script that detects clicks on every element on the page. I’d like that to run on everything except a specific div and its children.

I’ve tried doing this using the :not selector, but don’t really understand how to use that effectively, so I’m not sure if that’s the right way to go or not.

Here’s some sample code:

<div id="clickme">This is good stuff</div>

<div id="dontclickme">This should not get selected</div>

I’m currently using $("*") for my selector. Is there a way to use that to detect if it’s the second div, or any of its children?

  • 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-16T11:15:20+00:00Added an answer on June 16, 2026 at 11:15 am

    You can use .filter() with .closest() to check if element has a certain id or element is a children/descendant of element with certain id…

    $('body *').filter(function(i, v) {        
        return $(v).closest('#dontclickme').length == 0;
    })
    

    http://jsfiddle.net/wirey00/7JE7x/

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

Sidebar

Related Questions

Possible Duplicate: jquery or css selector? select all id’s that start with I need
Possible Duplicate: jquery on vs click methods I understand that $(parent).on('click', 'element', function(){ ...
Possible Duplicate: jQuery delay between animations I have created two functions: One that animates
Possible Duplicate: jquery v1.3.2 find element by attribute Is it possible to grab a
Possible Duplicate: jQuery disable SELECT options based on Radio selected (Need support for all
Possible Duplicate: jQuery bind click ANYTHING but ELEMENT I have this HTML <div id=outer>
Possible Duplicate: jQuery id selector works only for the first element I want jquery
Possible Duplicate: jQuery, get html of a whole element lets say I have: <span>my
Possible Duplicate: jquery finish one animation then start the other one I've got a
Possible Duplicate: jquery - How to select all content between two tags Suppose I

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.