如何手动触发我使用jQuery连接的事件?

Bla*_*man 0 jquery

如何在我之前使用jQuery连接的按钮上手动触发单击事件?

cgp*_*cgp 6

使用触发器.(链接到触发器的文档)

$("button:first").click(function () {
  update($("span:first"));
});
$("button:last").click(function () {
  $("button:first").trigger('click');

  update($("span:last"));
});

function update(j) {
  var n = parseInt(j.text(), 10);
  j.text(n + 1);
}
Run Code Online (Sandbox Code Playgroud)