File partial.html looks like this: <button id="test">Hi I am from a partial!</button>
Partial.html
is dynamically included on the page, using XMLHttpRequest
:
var oReq = new XMLHttpRequest();
oReq.open('get', 'partial.html', true);
oReq.send();
oReq.onload = function() {
document.querySelector('#pageArea').innerHTML = this.response;
};
How can I add an event listener that will apply to future exisiting #test
without doing it after it's content has been loaded and inserted into #pageArea
?
(No jQuery solutions, please!)