How to enable and disable onclick event

user1136575
function my_function () {} (...)

// enabling onlick event
$("#link").prop("onclick", "my_function()");

// disabling onlick event
$("#some_button_click").click() {
    $("#link").prop("onclick", null);
}

I have a button that should disable an onlick event. That is fine. But then, I need to reset the onclick event to the initial state, which is enable.

How can I do that?

PSL

You are using jquery. so use on() and off() for 1.7+ or use bind() / unbind() for earlier versions.

  $("#link").on("click", my_function);


  // disabling onlick event
  $("#some_button_click").click(function(){
    $("#link").off("click");
  });

Also you do have some syntax issues in your current code pasted.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to disable and then enable onclick event on <div> with javascript

From Dev

disable / enable addeventlistener onclick

From Dev

Android : How to disable Keyboard or making enable only the numeric in EditText onClick

From Dev

Android : How to disable Keyboard or making enable only the numeric in EditText onClick

From Dev

How to enable and disable the button in a checked event of checkbox in jQuery?

From Dev

How can i enable/disable a button in a backgroundworker DoWork event?

From Dev

How to enable and disable css transition in one js-event?

From Dev

how to disable a button's onClick() event for some time?

From Dev

Disable an event and again enable the event back in jQuery

From Dev

Disable Onclick event using jquery

From Dev

How to enable / disable a Preference?

From Dev

How to enable or disable services?

From Dev

How to enable or disable services?

From Dev

How to enable / disable a Preference?

From Dev

How to Enable and Disable Buttons

From Dev

How to enable/disable a checkbox

From Dev

jQuery - Enable Disable (Toggle) Selectbox onClick Button

From Dev

enable and disable the edittext in android onclick of CheckBox

From Dev

enable disable dates in jquery calendar on change event

From Dev

Is there a listener that listens to the enable/disable event in Swing?

From Dev

Button enable and disable on text changed event

From Dev

How to: Disable (and re-enable) a ToggleButton Event Trigger (Storyboard - Double Animation)

From Dev

jQuery: Disable onclick event using off() not working

From Java

How to enable/disable inputs in blazor

From Dev

How to disable and enable keyboard in ubuntu?

From Dev

How to enable and disable qDebug() messages

From Dev

How to disable/enable prefetching in GCC?

From Dev

How to enable/disable trigger in procedure?

From Dev

How to programmatically disable/enable a UIBarButtonItem

Related Related

  1. 1

    How to disable and then enable onclick event on <div> with javascript

  2. 2

    disable / enable addeventlistener onclick

  3. 3

    Android : How to disable Keyboard or making enable only the numeric in EditText onClick

  4. 4

    Android : How to disable Keyboard or making enable only the numeric in EditText onClick

  5. 5

    How to enable and disable the button in a checked event of checkbox in jQuery?

  6. 6

    How can i enable/disable a button in a backgroundworker DoWork event?

  7. 7

    How to enable and disable css transition in one js-event?

  8. 8

    how to disable a button's onClick() event for some time?

  9. 9

    Disable an event and again enable the event back in jQuery

  10. 10

    Disable Onclick event using jquery

  11. 11

    How to enable / disable a Preference?

  12. 12

    How to enable or disable services?

  13. 13

    How to enable or disable services?

  14. 14

    How to enable / disable a Preference?

  15. 15

    How to Enable and Disable Buttons

  16. 16

    How to enable/disable a checkbox

  17. 17

    jQuery - Enable Disable (Toggle) Selectbox onClick Button

  18. 18

    enable and disable the edittext in android onclick of CheckBox

  19. 19

    enable disable dates in jquery calendar on change event

  20. 20

    Is there a listener that listens to the enable/disable event in Swing?

  21. 21

    Button enable and disable on text changed event

  22. 22

    How to: Disable (and re-enable) a ToggleButton Event Trigger (Storyboard - Double Animation)

  23. 23

    jQuery: Disable onclick event using off() not working

  24. 24

    How to enable/disable inputs in blazor

  25. 25

    How to disable and enable keyboard in ubuntu?

  26. 26

    How to enable and disable qDebug() messages

  27. 27

    How to disable/enable prefetching in GCC?

  28. 28

    How to enable/disable trigger in procedure?

  29. 29

    How to programmatically disable/enable a UIBarButtonItem

HotTag

Archive