homepage Welcome to WebmasterWorld Guest from 54.166.10.100
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Multiple events one function
Rain_Lover




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

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




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

You could create your own function to wrap these calls:

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

Rain_Lover




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

Thanks for the answer! It gave me some ideas.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved