Hello interested in the question of how to trigger an event on the checkbox of the form that would enter into the console and a check mark appeared.
var elem = document.forms[0][0] var event = document.createEvent('HTMLEvents') event.initEvent("change", false, false); elem.dispatchEvent(event) this does not work, and the following also does not work:
elem = document.forms[0][0] var event = new Event("change"); elem.dispatchEvent(event); But as I understand it, the last option is to set up a custom event, but at the same time, the software form submit works:
elem = document.forms[0] var event = new Event("submit"); elem.dispatchEvent(event); And with the checkbox, not only change , but focus does not work (construction: var elem = document.forms[0][0]; elem.focus() generally returns undefined).
What am I doing wrong? How to call a chande on the checkbox or focus at least?
PS I know how to do it on jQuery, pure JS (Chrome browser) is interested.