Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Event on every click on the page, except one element.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
NMarcu  
View profile  
 More options Nov 6, 11:13 am
From: NMarcu <marcu.nico...@gmail.com>
Date: Fri, 6 Nov 2009 08:13:19 -0800 (PST)
Local: Fri, Nov 6 2009 11:13 am
Subject: Event on every click on the page, except one element.
Hello all,

    I want to do something like this:

    On every click event, on the page, but except on specific element,
with id="elem_id" to do something. The element with id="elem_id" need
to update a table. And when I click on something else, that is not the
element with id="elem_id" I want that table to come back on the
original form. I'm intresting only in the jquery syntax, how can I
select all page, without a specific element, on click event.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leonardo K  
View profile  
 More options Nov 6, 11:22 am
From: Leonardo K <leo...@gmail.com>
Date: Fri, 6 Nov 2009 14:22:21 -0200
Local: Fri, Nov 6 2009 11:22 am
Subject: Re: [jQuery] Event on every click on the page, except one element.

$(document).ready(function(){
    $('body').click(function(e){
        var elem = e.target;
        if ( $(elem).attr('id') != "elem_id" ){
            //do something
        }else{
            //do something
        }
    });


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leonardo K  
View profile  
 More options Nov 6, 11:31 am
From: Leonardo K <leo...@gmail.com>
Date: Fri, 6 Nov 2009 14:31:40 -0200
Local: Fri, Nov 6 2009 11:31 am
Subject: Re: [jQuery] Event on every click on the page, except one element.

Example: http://jsbin.com/iraqo
Edit to view the source: http://jsbin.com/iraqo/edit


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicu Marcu  
View profile  
 More options Nov 6, 11:45 am
From: Nicu Marcu <marcu.nico...@gmail.com>
Date: Fri, 6 Nov 2009 18:45:44 +0200
Local: Fri, Nov 6 2009 11:45 am
Subject: Re: [jQuery] Event on every click on the page, except one element.

Can I do something like this:
$(document).ready(function(){
    $('body').click(function(e){
        var elem = e.target;
        if ( $(elem).attr('class') != "elem_class" ){
            //do something
        }else{
            //do something
        }
    });

});

I need to select by class? If I have more elements in a div with
id="div_id", can I use this id, and all elements will be passend from click
event?

2009/11/6 Leonardo K <leo...@gmail.com>

--
All the best,

Nicolae MARCU


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leonardo K  
View profile  
 More options Nov 6, 12:35 pm
From: Leonardo K <leo...@gmail.com>
Date: Fri, 6 Nov 2009 15:35:26 -0200
Local: Fri, Nov 6 2009 12:35 pm
Subject: Re: [jQuery] Event on every click on the page, except one element.

If your id is a container u need to traverse the element to find the parent.

<div id="aaa">
    <div>
        <p>asdasd</p>
    </div>
</div>

If you click the asdasd will return the p element. U could do
$(elem).closest('#aaa') to find the element that you want.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicu Marcu  
View profile  
 More options Nov 6, 2:33 pm
From: Nicu Marcu <marcu.nico...@gmail.com>
Date: Fri, 6 Nov 2009 21:33:12 +0200
Local: Fri, Nov 6 2009 2:33 pm
Subject: Re: [jQuery] Event on every click on the page, except one element.

I have a div like this:
<div id="tab_informations">
                <fieldset>
                    <label for="name">Name</label>
                    <input type="text" name="name" id="name" class="text
ui-widget-content ui-corner-all"/>
                    <label for="password">Password</label>
                    <input type="password" name="password" id="password"
class="text ui-widget-content ui-corner-all"/>
                    <label for="email">Email</label>
                    <input type="text" name="email" id="email" class="text
ui-widget-content ui-corner-all" />
                    <label for="firstname">First Name</label>
                    <input type="text" name="firstname" id="firstname"
class="text ui-widget-content ui-corner-all" />
                    <label for="lastname">Last Name</label>
                    <input type="text" name="lastname" id="lastname"
class="text ui-widget-content ui-corner-all"  />
                </fieldset>
  </div>

How can I set to not react on click event on all elements on this div?

Like this, not working:

$('body').click(function(e){
                    var elem = e.target;

                    if ( $(elem).attr('id') != "tab_informations"{
                   //do something
                    }

});

2009/11/6 Leonardo K <leo...@gmail.com>

--
All the best,

Nicolae MARCU


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mkmanning  
View profile  
 More options Nov 6, 2:50 pm
From: mkmanning <michaell...@gmail.com>
Date: Fri, 6 Nov 2009 11:50:29 -0800 (PST)
Local: Fri, Nov 6 2009 2:50 pm
Subject: Re: Event on every click on the page, except one element.
user .is() and pass selectors for the elements you want to match:

$(document).ready(function(){
        $('body').click(function(e){
                e = $(e.target);
                if(!e.is('.ui-widget-content,label,fieldset')){
                        console.log('test');
                }
        });

});

On Nov 6, 11:33 am, Nicu Marcu <marcu.nico...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mkmanning  
View profile  
 More options Nov 6, 4:39 pm
From: mkmanning <michaell...@gmail.com>
Date: Fri, 6 Nov 2009 13:39:31 -0800 (PST)
Local: Fri, Nov 6 2009 4:39 pm
Subject: Re: Event on every click on the page, except one element.
and you could use
...
if(!e.is('#tab_informations *')){
...
On Nov 6, 11:50 am, mkmanning <michaell...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google