I don't know much about Javascript but I though the .click mand was the way to simulate a click on an item, let's say with something like
document.getElementById('id').click
I recently found a webpage where the buttons .click mand did not triggered anything though my actual real clicks do.
I dug a bit and found that there are no event on the onclick of those buttons though they seem to have some eventlistener attached.
Hence I am looking to the proper mand out of my Chrome console to trigger the event without actually clicking. Anyone can help on this?
Regards
I don't know much about Javascript but I though the .click mand was the way to simulate a click on an item, let's say with something like
document.getElementById('id').click
I recently found a webpage where the buttons .click mand did not triggered anything though my actual real clicks do.
I dug a bit and found that there are no event on the onclick of those buttons though they seem to have some eventlistener attached.
Hence I am looking to the proper mand out of my Chrome console to trigger the event without actually clicking. Anyone can help on this?
Regards
Share Improve this question edited Jul 16, 2019 at 17:35 Tobias Tengler 7,4744 gold badges25 silver badges34 bronze badges asked Jun 24, 2018 at 19:58 samuel guedonsamuel guedon 6261 gold badge9 silver badges23 bronze badges3 Answers
Reset to default 4Ok that was a very stupid question from me thanks to my lack of knowledge of javascript (and tiredness maybe regarding how easy the answer is).
So I just lacked a few parenthesis in my click mand...
(EDIT: fixed typo in method)
document.getElementById('id').click()
And now it's fine... sorry for bothering you and thanks to @Kasabucki Alexandr who indirectly showed me the correct answer
You can just type in console something like this: document.getElementById('notify-container');
let a = document.getElementById('notify-container');
a.addEventListener('click', () => console.log('asdfsd'));
document.getElementById('notify-container').click()
<div id="notify-container"></div>
Do you think about addEventListener?