按钮点击不会触发功能

时间:2020-02-19 20:39:42

标签: javascript jquery function button click

我在触发功能时遇到问题。我有以下代码:

var dnfmomd;

dnfmomd = new function () {
//function content
}

$("#launch_button").on("click", dnfmomd.init);

2 个答案:

答案 0 :(得分:0)

您尝试过吗?

var dnfmomd = function () {
//function content
}

$("#launch_button").on("click", dnfmomd());

答案 1 :(得分:0)

我建议这样做

 var dnfmomd = function() {
 //function content
}

$("#launch_button").on("click", function() {
  dnfmomd();
});