Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2009
    Posts
    199
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Multiple events one function

    The following works with no problem:

    Code:
    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?

  • #2
    Regular Coder
    Join Date
    May 2012
    Location
    France
    Posts
    224
    Thanks
    0
    Thanked 32 Times in 30 Posts
    Try this must shorter way ...
    Code:
    element.oninput = element.onchange = go;
    Last edited by 007julien; 05-14-2014 at 09:34 AM.

  • Users who have thanked 007julien for this post:

    Rain Lover (05-14-2014)

  • #3
    Regular Coder
    Join Date
    Nov 2009
    Posts
    199
    Thanks
    23
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by 007julien View Post
    Try this must shorter way ...
    Code:
    element.oninput = element.onchange = go;
    Thanks for the answer! onchange is added to support IE and oninput for other browsers to handle an <input type="range">. Does the events order make any difference?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •