Hi Julien,

May I propose a different way?

$('input:checkbox, input:text').bind('change focus', function(event) {
  if (event.type == 'change' || this.type == 'text') {
    $(this).parent().nextAll().find('input:text').doSomething();
  }
});

This selects all checkboxes and text inputs and binds both a change and a focus handler to them. The doSomething() method will fire on change regardless of the input type (event.type == 'change') and on focus for text inputs only (this.type == 'text')

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Oct 16, 2009, at 6:02 AM, Julien wrote:


Thanks a lot, Karl. Your code dit it.

Now are several events (like key strokes and checkbox changes) for
which the same code must be run.
So, I would like to retrieve the siblings from within a function.

The problem I encounter with the code below is how to retrieve in
jQuery the "caller" argument passed to the function ?  Is there some
general syntax to read variables ?

$(':text')
    .focus( function { UpdateFooter(this) } )
    .change( function { UpdateFooter(this) } )

$(':checkbox')
    .change( function { UpdateFooter(this) } );

function UpdateFooter (caller) {
   $(caller).parent().nextAll().find('input:text').each(doSomething
());   // Which syntax to read the parameter ?
}


On 15 oct, 19:31, Karl Swedberg <k...@englishrules.com> wrote:
Provided that all the text inputs located after it are within the same
<ul>, this should do it:

$('input:text').change(function() {
   $(this).parent().nextAll().find('input:text').doSomething();

});
(skipped)

Reply via email to