Answer the question
In order to leave comments, you need to log in
How to enter text into input?
There is a search engine on YouTube and you need to enter text there, but it doesn’t work with a script, but I understand that it works on pressing and then you can enter
this, I tried it didn’t work
document.getElementById('search').value = 'Hi'
Answer the question
In order to leave comments, you need to log in
This is not enough, it is necessary for the JavaScript on the page to understand that the text in the field has changed.
After inserting, make the handlers that the site set for this field work:
document.querySelector('#search').dispatchEvent(new Event('input'));
document.querySelector('#search').dispatchEvent(new Event('change'));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question