Firing events on CSS class changes in jQuery

后端 未结 13 904
天涯浪人
天涯浪人 2020-11-22 04:45

How can I fire an event if a CSS class is added or changed using jQuery? Does changing of a CSS class fire the jQuery change() event?

13条回答
  •  不思量自难忘°
    2020-11-22 04:55

    There is one more way without triggering an custom event

    A jQuery Plug-in to monitor Html Element CSS Changes by Rick Strahl

    Quoting from above

    The watch plug-in works by hooking up to DOMAttrModified in FireFox, to onPropertyChanged in Internet Explorer, or by using a timer with setInterval to handle the detection of changes for other browsers. Unfortunately WebKit doesn’t support DOMAttrModified consistently at the moment so Safari and Chrome currently have to use the slower setInterval mechanism.

提交回复
热议问题