Try this: var unwanted = $('#addNewAdress,#addNewContactDetail'); $('input').not(unwanted).click(function(){ console.log(this.id); });
This is exactly the same as your first posted code, I just tested and it works. What does your HTML look like? On Dec 16, 1:26 pm, WhoButSB <whobu...@gmail.com> wrote: > I gave this a try: > $("input:not(#addNewAddress:input, #addNewContactDetail:input)").focus > (); > > And the function would still run :-/ . Maybe I should use the input > selector then add a class to the ones i don't want to grab and use the > hasClass method to return a false for the ones not supposed to > activate. > > But I have to believe there is an easier way. > > On Dec 15, 7:39 pm, Kean <shenan...@gmail.com> wrote: > > > This probably will work too. > > > $("input:not(#addNewAddress, #addNewContactDetail)").click(); > > > On Dec 15, 3:01 pm, "Rik Lomas" <lomas....@gmail.com> wrote: > > > > Try: > > > > $("input").not('#addNewAddress, #addNewContactDetail').click(); > > > > Rik > > > > 2008/12/15 WhoButSB <whobu...@gmail.com>: > > > > > Hello All! > > > > I'm trying to figure out the correct way to use the not() method. I > > > > know there is also a :not() filter in selectors class but I couldn't > > > > get that one to work either. > > > > > My goal is to add a click function to all the input fields on a page. > > > > But not select the input buttons that are nested in certain divs. > > > > > Here is what I have tried so far: > > > > > $("input").not($('#addNewAddress:input', > > > > '#addNewContactDetail:input')).click(function(){ > > > > console.log($(this).attr('id')); > > > > }); > > > > > AND > > > > > $("input").not('#addNewAddress input', '#addNewContactDetail > > > > input').click(function(){ > > > > console.log($(this).attr('id')); > > > > }); > > > > > Neither have worked so far. Should I be using the :not() command in > > > > the selector? > > > > > Thanks for the help! > > > > -- > > > Rik Lomashttp://rikrikrik.com