I created a snippet in chrome devtools but it throws this error when I run it:
Uncaught TypeError: element.dispatchEvent is not a function
at changeValue (:12:11)
at :15:1
This is my code:
var script = document.createElement("script");
script.setAttribute("src", "//code.jquery.com/jquery-latest.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
const changeValue = (element, value) => {
const event = new Event('input', { bubbles: true })
element.value = value
element.dispatchEvent(event)
}
changeValue($('#typeahead-input-to'), 'Syd');
Is there any way I can get this code to work by running it in the chrome console?