How to call multiple JavaScript functions in onclick event?

后端 未结 11 802
梦如初夏
梦如初夏 2020-11-22 06:25

Is there any way to use the onclick html attribute to call more than one JavaScript function?

11条回答
  •  [愿得一人]
    2020-11-22 07:17

    I would use the element.addEventListener method to link it to a function. From that function you can call multiple functions.

    The advantage I see in binding an event to a single function and then calling multiple functions is that you can perform some error checking, have some if else statements so that some functions only get called if certain criteria are met.

提交回复
热议问题