How to Set OnClick attribute with value containing function in ie8?
You don’t need to use setAttribute for that – This code works (IE8 also) <div id=”something” >Hello</div> <script type=”text/javascript” > (function() { document.getElementById(“something”).onclick = function() { alert(‘hello’); }; })(); </script>