0

Today I made some screens in the software I develop, and I need detect when an input is being disabled and enabled to show/hide another element. I know how to do it by bind the checkbox which enables and disables my input, but I want to know whether there is a way to handle the input instead of checkbox.

Thanks

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Márcio Gonzalez
  • 1,020
  • 1
  • 8
  • 20
  • use $(input).attr("enabled")...It will return true or false – Hammad Jun 24 '15 at 13:22
  • @Hammad 1) there is no enabled attribute - perhaps you mean `$( "input:enabled" )` which is a collection 2) that will not detect WHEN it is disabled/enabled – mplungjan Jun 24 '15 at 13:25
  • @GregBurghardt no answer in that link covers the disabling/enabling – mplungjan Jun 24 '15 at 13:29
  • @mplungjan: Yes it does. The `propertychange` event in jQuery covers this. – Greg Burghardt Jun 24 '15 at 13:53
  • Hi guys. I saw that link and setInterval is not an option to me. The software follows a design pattern and I can't use it. Our software is compatible with IE9+ and I think propertychanged event will not fire. – Márcio Gonzalez Jun 24 '15 at 14:03
  • @GregBurghardt I do not see that work in Chrome: http://jsfiddle.net/mplungjan/qngaqjkL/ – mplungjan Jun 24 '15 at 14:45
  • I found a way. I need to learn more about it, but it's a way. Using javascript MutationObserver object I got the expected result. But it is only compatible with IE11+ More information about this object here: https://developer.mozilla.org/pt-BR/docs/Web/API/MutationObserver#MutationObserverInit – Márcio Gonzalez Jun 24 '15 at 15:15

0 Answers0