How to override jQuery event handlers?

jQueryWeb DevelopmentFront End Technology

Use the off() method to override jQuery event handlers. This method is used to remove an event handler. The on() method is used to attach one or more event handler.


You can try to run the following code to learn how to override jQuery event handlers −

Live Demo


      <title>jQuery off() method</title>
      <script src = ""></script>
         $(document).ready(function() {

            function aClick() {
            $("#bind").click(function () {
               $("#theone").on("click", aClick).text("Can Click!");
            $("#unbind").click(function () {
               $("#theone").off("click", aClick).text("Does nothing...");
         button {
         button#theone {
      <button id = "theone">Does nothing...</button>
      <button id = "bind">Bind Click</button>
      <button id = "unbind">Unbind Click</button>
      <div style = "display:none;">Click!</div>
Published on 20-Dec-2017 12:59:53