I tried to trigger click event of button after 3 mins using below javascript code
setTimeout(function(){$(‘._my_save_button’).trigger(‘click’)},180000);
Above code throws error when we run in chrome console
Uncaught SyntaxError: Invalid or unexpected token
I tried to trigger click event of button after 3 mins using below javascript code
setTimeout(function(){$(‘._my_save_button’).trigger(‘click’)},180000);
Above code throws error when we run in chrome console
Uncaught SyntaxError: Invalid or unexpected token
Share
edited Mar 13, 2019 at 16:02
rocky
asked Mar 13, 2019 at 15:57
rockyrocky
8312 gold badges11 silver badges31 bronze badges
4
-
2
setTimeout(function(){$('_my_save_button').trigger('click')},180000);
..............‘_my_save_button’
=>'_my_save_button'
– Pranav C Balan Commented Mar 13, 2019 at 15:59 -
2
Your single quotes are 'weird'. Try using normal single (or double) quotes:
'
or"
. Also, your_my_save_button
is really nothing. If it's the id of the button, you should add the prefix#
to that. – ZiNNED Commented Mar 13, 2019 at 15:59 -
does your button have the class or id
_my_save_button
? if it is the class, prepend it with a.
, if id, prepend with#
. – Matthew Varga Commented Mar 13, 2019 at 16:00 - Looks like dublicate of stackoverflow./q/7188145/8623919 – Bijay Yadav Commented Mar 13, 2019 at 16:06
2 Answers
Reset to default 6We 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.
should be "#_my_save_button"
in case of id="_my_save_button"
or "._my_save_button"
in case of class="_my_save_button"
:
setTimeout(function(){$("#_my_save_button").trigger("click")},180000);