Forum Moderators: open

Message Too Old, No Replies

Multiple events one function

         

Rain_Lover

3:17 am on May 14, 2014 (gmt 0)

10+ Year Member Top Contributors Of The Month



The following works with no problem:

element.oninput = go;
element.onchange = go;
...


But isn't there a shorter way to achieve the same result? Do we have to repeat the same line for each event?

Fotiman

1:16 pm on May 14, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You could create your own function to wrap these calls:

function onvalchanged(element, go) {
element.oninput = go;
element.onchange = go;
}

Rain_Lover

3:59 pm on May 14, 2014 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks for the answer! It gave me some ideas.