Add "enable" and "disable" methods to jQuery. Chainable, and can take callbacks.
In our project I noticed we enable and disable various interactive elements. So I thought: "wouldn't it be neat if I could just call .disable()
and .enable()
on them?". So now I can. And you can, too.
What it actually does:
- adds/removes a class "disabled"
- sets/unsets attribute "disabled" on an element.
- deals with fake buttons (spans, divs) by wrapping them & inserting a "masking" div that catches and blocks click events.
I'm a novice! Help me make it better :) Fork & pull-request.