Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.javascript Subject: Re: Multiple inputs with same event Date: Sun, 7 Jun 2020 11:06:07 +0200 Lines: 22 Message-ID: References: <9KednS9A0scWq0HDnZ2dnUU7-TnNnZ2d@westnet.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net EhuoJ4TAcsbxiddfVCmi2wYP+VK2AFZo6eD6xP/hCgNVFJFoM0 Cancel-Lock: sha1:9Lu7Zjq2y0JAk48b/NGG3XGrJSA= In-Reply-To: <9KednS9A0scWq0HDnZ2dnUU7-TnNnZ2d@westnet.com.au> Xref: csiph.com comp.lang.javascript:38448 Andrew Poulos: [...] > Is there a way for multiple inputs to call the same function when the > same event occurs to any of them without directly attaching the event to > each input? Or should a just write a function that dynamically attaches > the required events? Without attaching the event to a handler there is handler at all. If you need different handlers for different input element types, iterate through the DOM and attach the handler depending on the type. one for blur events and another for checking or unchecking things. But however you do it - there is no other way than attaching an event handler to each input element. There is no gobal "some input has some change" event. -- Arno Welzel https://arnowelzel.de