Javascript function call - Javascript Function

Javascript examples for Function:Function Call

Description

Javascript function call

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <input id="bike" type="checkbox" name="vehicle" data-a="10" data-b="10" value="Bike">
      this is a test
      <br> 
      <script type="text/javascript">
var bike = document.getElementById('bike');
bike.onclick = add;/*from w  ww .ja  v a2 s .  c  o  m*/
function add() {
  var a = +this.dataset.a;
  var b = +this.dataset.b;
  console.log(a+b);
  return a + b;
}

      </script>  
   </body>
</html>

Related Tutorials