'how to add onchnage event on auto genrated html by javascript?

everyone. I am trying to use an api which is by tom tom places autocomplete. there is a code as below:

    var ttSearchBox = new tt.plugins.SearchBox(tt.services, options);
    var searchBoxHTML = ttSearchBox.getSearchBoxHTML();
    $('#pickup_city').after(searchBoxHTML);

which generates a input field as below in my html code:

<input class="tt-search-box-input" placeholder="">

what i want to add an onchange argument to this input field like this:

  <input class="tt-search-box-input" placeholder="" onchange="myFunction()">

but i dont know how to do it? can anyone tell me how can i achhieve this?

here is the code from js :

 "getSearchBoxHTML", (function() {
            return n._container
        }))

and the n._container is :

n._container = document.createElement("div"), n._container.className = ".tt-search-box", 
 n._inputWrapper = new A(n._container, n.store, n.userActions), n._resultList = new 
 j(n._container, n.store, n.userActions), n._container

Thanks in advance <3



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source