Is it possible to listen to a “style change” event?

前端 未结 11 1110
南笙
南笙 2020-11-22 08:03

Is it possible to create an event listener in jQuery that can be bound to any style changes? For example, if I want to \"do\" something when an element changes dimensions, o

11条回答
  •  无人及你
    2020-11-22 08:39

    I had the same problem, so I wrote this. It works rather well. Looks great if you mix it with some CSS transitions.

    function toggle_visibility(id) {
       var e = document.getElementById("mjwelcome");
       if(e.style.height == '')
          e.style.height = '0px';
       else
          e.style.height = '';
    }
    

提交回复
热议问题