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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:05:22+00:00 2026-06-06T11:05:22+00:00

So I have a page setup that lets you expend text boxes upon click:

  • 0

So I have a page setup that lets you expend text boxes upon click:

http://hashtag.ly/#NASCAR

It adds an ‘active’ class to elements upon click and removes it if you click another text box. Now I’d like remove the class if you click on the red background. I’ll also want to add elements to the page shortly so it’s important that this removal only comes from clicking the red portion which is the <body> element.

So here’s what I have on the page now: (note the log will be replaced by the removal of the class)

$('*:not(li)').click(function(){
    console.log('foo')
});

The problem is it logs ‘foo’ everywhere you click, even directly on the text boxes which are li elements. How can I make this work only upon click of the background?

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-06T11:05:24+00:00Added an answer on June 6, 2026 at 11:05 am

    Your problem is that you’re bubbling down the HTML stack. By putting the handler on everything, even if you click on an LI, the event will bubble up to its UL. Similarly, $(‘body’) will cause bubbling issues.

    You’re best off creating a div outside of your main stack to handle this. Imagine an absolutely positioned div behind most of the page.

    If you really want to have everything fire except for LI, your code would need to look more like this:

    $('*:not(li)').click(function(){
    // do something.
    });
    $('li').click(function(evt){
    // do something else.
        evt.stopPropagation();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page setup with a scroll bar that is set with a
I have a page that is setup like this public partial class _Default :
Here's my setup. I'm using .NET: I have a Main.aspx lets call it. That
Lets say I have a page on the same domain that I put inside
I have a setup that sets variables for the index page, but it also
So, I have set up a login page that verifies the user's credentials, and
Can you setup a variable for javascript in one page and have another page
On my portfolio page I have this setup: <div id=portfolio> <ul id=sites> <li> <h3><a
I have a requirement to return xml as follow <row id=1> <cell>1</cell> <cell>setup/pagemst</cell> <cell>Page
I have an application that lets users get a *.onemobi.net account (ex. bob.onemobi.net ).

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.