<div id="id1" onclick="Function1()">Click on me</div>
<script>
var id1 = document.getElementById("id1");
id1.outerHTML = id1.outerHTML.replace('onclick="Function1()"', 'onclick="Function2()"');
alert(id1.outerHTML);
alert(document.getElementById("id1").outerHTML);
function Function1(){
alert('Function1 is executed!');
}
function Function2(){
alert('Function2 is executed!');
}
</script>