How to call multiple JavaScript functions in onclick event?

后端 未结 11 1102
梦如初夏
梦如初夏 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:27

    This is the code required if you're using only JavaScript and not jQuery

    var el = document.getElementById("id");
    el.addEventListener("click", function(){alert("click1 triggered")}, false);
    el.addEventListener("click", function(){alert("click2 triggered")}, false);
    

提交回复
热议问题