在JavaScript中一段时间​​后如何触发按钮的点击事件

时间:2019-03-13 15:57:13

标签: javascript jquery

我尝试使用以下JavaScript代码在3分钟后触发按钮的点击事件

setTimeout(function(){$(‘._my_save_button’).trigger(‘click’)},180000);

在chrome控制台中运行时,上述代码会引发错误

Uncaught SyntaxError: Invalid or unexpected token

2 个答案:

答案 0 :(得分:3)

我们需要在您的标识符周围加上引号。

res.partner

答案 1 :(得分:0)

我认为您只缺少正确的CSS选择器。

let result = [ { name: 'dashboard', path: '/dashboard', id: 'my-dashboard-id', someotherprop: someothervalue ... }, { name: 'dashboard.settings', path: '/dashboard/settings', id: 'my-settings-id', someotherprop: someothervalue ... }, { name: 'dashboard.settings.user', path: '/dashboard/settings/user', id: 'my-user-id', someotherprop: someothervalue ... }, { name: 'dashboard.settings.email', path: '/dashboard/settings/email', id: 'my-email-id', someotherprop: someothervalue ... }, { name: 'dashboard.settings.email.template', path: '/dashboard/settings/email/template', id: 'my-template-id', someotherprop: someothervalue ... }, { name: 'dashboard.settings.email.template.error', path: '/dashboard/settings/email/template.error', id: 'my-error-id', someotherprop: someothervalue ... }, ..... ] 的情况下应为"#_my_save_button"id="_my_save_button"(如果是"._my_save_button"

class="_my_save_button"