jQuery Form How to - Stop click event on button








Question

We would like to know how to stop click event on button.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.7.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--from   ww w  .java 2  s  .com-->
        $(function() {
            $(".upvote").on("click", function(e){
                e.preventDefault();
                console.log('test');
            });
        }); 
});
</script>
</head>
<body>
  <form action="#" method="post">
    <input type="submit" class="upvote" value=" + " />
  </form>
</body>
</html>

The code above is rendered as follows: