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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:53:56+00:00 2026-05-29T23:53:56+00:00

I have the following HTML: <div data-role=page id=some> <p>Hello world</p> <div data-role=panel id=panel> <p>I’m

  • 0

I have the following HTML:

 <div data-role="page" id="some">               
    <p>Hello world</p>
    <div data-role="panel" id="panel">
      <p>I'm a panel</p>
    </div>
 </div>

I need to fire a function if the user clicks on the page, but not if he clicks on the panel.

Is this possible = registering a click on an element excluding some of it’s children? I’m currently trying like this but it doesn’t seem to work:

 $('div:jqmData(role="page"):not(#panel)').live('click tap', function(event) {
    console.log("registered a click");
    // fire a function
    });
  • 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-29T23:53:57+00:00Added an answer on May 29, 2026 at 11:53 pm

    Match the event.target object against a selector.
    Use .parentsUntil(<elementTostopAt>, <selector>) to traverse up the tree, to make sure that we did not click on a child of the forbidden element. To include the clicked element, use .andSelf().

    The previously described methods return a jQuery collection of elements. Check the size of this property using .length. If the size is non-zero, return.

    $('div:jqmData(role="page")').live('click tap', function(event) {
        if ($(event.target).parentsUntil(this, '#panel').andSelf().length) return;
        console.log("registered a click");
        // fire a function
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML on a Jquery Mobile Page: <div data-role=controlgroup data-type=horizontal class=panelSwitcher>
I have the following jQueryMobile page anatomy at index.html: <div data-role=page> <div data-role=header>...</div> <div
I have the following HTML: <div class='sidebar-listview ui-listview' data-role='listview' data-theme='c'> <li class='ui-li ui-li-static ui-body-c
I have the following HTML: [...] <div class=row clearfix> <div class=col1>Data</div> <div class=col2>Data</div> <div
I have the following HTML <div id=testID class=test1> <img id=testID2 class=test2 alt= src=some-image.gif />
I have the following html <div id=to-sort> <div class=block data-id=1>aaaaa</div> <div class=block data-id=2>bbbbb</div> <div
I have the following html code: <div id=result1 class=result> ... some html ... ...
I have following HTML <div id=finalTree> <ul> <li class=last style=display: list-item;> <a id=DataSheets href=#>Data
I have the following html <div id=menu> <ul class=horizMenu> <li id=active><a href=# id=current>About</a></li> <li><a
I have the following HTML <div> <img id=image1 src=http://valleywag.com/assets/resources/2008/03/BlackGoogleLogo.jpg alt=Why doesn't this float correcly?

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.