There is another alternative: using setAttribute
rather than adding an event listener. Like this:
<!DOCTYPE html>_x000D_
<html>_x000D_
<head>_x000D_
<meta charset="utf-8">_x000D_
<title>Demo innerHTML and event listeners</title>_x000D_
<style>_x000D_
div {_x000D_
border: 1px solid black;_x000D_
padding: 10px;_x000D_
}_x000D_
</style>_x000D_
</head>_x000D_
<body>_x000D_
<div>_x000D_
<span>Click here.</span>_x000D_
</div>_x000D_
<script>_x000D_
document.querySelector('span').setAttribute("onclick","alert('Hi.')");_x000D_
document.querySelector('div').innerHTML += ' Added text.';_x000D_
</script>_x000D_
</body>_x000D_
</html>
_x000D_