jQuery Form How to - Handle button click event








Question

We would like to know how to handle button click event.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){<!--from w w w  .  j  ava2  s.  com-->
    $('.btn.btn-inverse').click(function(){
      console.log("Called");
    });
});//]]>  
</script>
</head>
<body>
  <button class="btn btn-inverse" type="submit">Login</button>
</body>
</html>

The code above is rendered as follows: