javascript - Triggering an event when a css value changes -
how can call function when specific css variable changes (eg: height of particular div), using jquery?
there no "native" solution this. if you're strictly using jquery manipulation of css propertys, function hook or (duck punshing) best shot:
(function($) { var _oldcss = $.fn.css; $.fn.css = function() { if( typeof arguments[0] === 'string' ) { console.log('css property ', arguments[0], ' change elem: ', this); } return _oldcss.apply(this, arguments); }; }(jquery));
this of course incomplete. if arguments[0]
object
need iterate on key/values. basic principle.
the thing solution is, .height()
call .css()
. so
$('div:eq(2)').height(55);
would trigger css property height change elem: [div#custom-header]
Comments
Post a Comment