Event after applied CSS rules on elements in jQuery/Javascript

China☆狼群 提交于 2019-12-05 20:01:06
Elliot Bonneville

As per here, you could grab the contents of the CSS file with AJAX and then use jQuery's built in complete call to tell when the CSS has loaded.

Such an event does not exist.

  • For all attribute changes, you can listen to the DOMAttrModifed mutation event.
  • Another option is to monitor specific style properties in an periodic function (interval),
  • Another method is to modify the jQuery.fn.css method, to intercept style changes via the jQuery API. This assumes that all relevant CSS property updates are done via jQuery.

    (function($){
        var $css = $.fn.css;
        $.fn.css = function(a,c) {
            if (c == null) return $css.call(this, a);
    
            return this.each(function() {
                var $this = $(this);
                // Your function logic...
                // ...
                // Call original method
                $css.call($this, a, c);
            });
        };
    })(jQuery);
    
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!