[英]How to trigger click event of button after period of time in javascript
I tried to trigger click event of button after 3 mins using below javascript code 我尝试使用以下javascript代码在3分钟后触发按钮的点击事件
setTimeout(function(){$(‘._my_save_button’).trigger(‘click’)},180000);
Above code throws error when we run in chrome console 当我们在Chrome控制台中运行时,上面的代码会引发错误
Uncaught SyntaxError: Invalid or unexpected token
We need to fix the quotes around your identifier. 我们需要在您的标识符周围加上引号。
setTimeout(function() {
$('._my_save_button').trigger('click');
}, 3000);
I think you are only missing the right css selector. 我认为您只缺少正确的CSS选择器。
should be "#_my_save_button"
in case of id="_my_save_button"
or "._my_save_button"
in case of class="_my_save_button"
: 应
"#_my_save_button"
中的情况下, id="_my_save_button"
或"._my_save_button"
中的情况下, class="_my_save_button"
:
setTimeout(function(){$("#_my_save_button").trigger("click")},180000);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.