title: change onclick function of the button dynamically using javascript
body: <p>How can I change onclick behavior of button dynamically using javascript?</p>
  
  <p>Here is what I meant:</p>
  
  <p>I have following buttons:</p>
  
  <pre><code>&lt;button class="num" onclick="getval(0)"&gt;0&lt;/button&gt;
  &lt;button class="num" onclick="getval(1)"&gt;1&lt;/button&gt;
  &lt;button class="num" onclick="getval(2)" &gt;2&lt;/button&gt;
  &lt;button class="num" onclick="getval(3)" &gt;3&lt;/button&gt;
  
  function getval(){
  
  ...............
  
  }
  
  function getvalNew(){
  
  ..............
  
  }
  </code></pre>
  
  <p>How can I make the buttons to switch from getval() to getvalNew() and reset it again?</p>