0

Is there some way to run a function when a input is disabled/enabled from another part of the code, for example when this code is run:

$('#myinput').prop('disabled', true);

I want another part of the code to be notified about this, but without making it dependent on the other part. Something similar to how "change" event works. But there's no "disabled" event...

thelolcat
  • 10,995
  • 21
  • 60
  • 102

2 Answers2

0

There is no event that will trigger when those properties are changed.

You can do this some other way.

Set hidden field for this enable disabled value like 1 / 0

$("#hiddenid").trigger("hiddenidchange");


$("#hiddenid").on("hiddenidchange", function () {

});

refer How do I trigger an onChange event for a hidden field?

Community
  • 1
  • 1
0

You can call notification trigger in the next line with an if statement

document.getElementById("email").disabled=true;
if(document.getElementById("email").disabled == true)
 {
   alert("Notifying..");
   //call the trigger function
 }
Rakesh Bk
  • 112
  • 15