Event detect when css property changed using Jquery

后端 未结 5 1067
北海茫月
北海茫月 2020-11-22 12:30

Is there a way to detect if the \"display\" css property of an element is changed (to whether none or block or inline-block...)? if not, any plugin? Thanks

5条回答
  •  孤城傲影
    2020-11-22 12:35

    You can use jQuery's css function to test the CSS properties, eg. if ($('node').css('display') == 'block').

    Colin is right, that there is no explicit event that gets fired when a specific CSS property gets changed. But you may be able to flip it around, and trigger an event that sets the display, and whatever else.

    Also consider using adding CSS classes to get the behavior you want. Often you can add a class to a containing element, and use CSS to affect all elements. I often slap a class onto the body element to indicate that an AJAX response is pending. Then I can use CSS selectors to get the display I want.

    Not sure if this is what you're looking for.

提交回复
热议问题