DEV Community

Discussion on: Can an html button have two onclick function?

Collapse
 
uzair004 profile image
Muhammad Uzair

By using event handler with html onclick property yoy are still using JavaScript functions because that handler is still JS function. In future you may need to add more handlers or delete or change one which is really handy when using separate JavaScript event listeners. Also removing certain handler or all of them is easy using functions like removeEventListener. also reusability is awesome in separate file.

Thread Thread
 
whataluckyguy profile image
Lalit Kumar • Edited

but @wick3drose is also right, for a very small project that didn't need any other handlers, Beginner can use that