1<script type="text/javascript">
2 function changeClass(){
3 // Code examples from above
4 }
5
6 window.onload = function(){
7 document.getElementById("MyElement").addEventListener( 'click', changeClass);
8 }
9</script>
10...
11<button id="MyElement">My Button</button>
12