Surasin Tancharoen
Surasin Tancharoen

Reputation: 5860

Any ways to detect CSS changing?

I have this tags:

<div>
   <h1>
   </h1>
</div>

Then I have a javascript lib that changes font-size of the <div> tag, but <h1> has its own CSS. Then text in <h1> does not change. I just want resizing font-size of <div> affecting <h1>. I cannot change the javascript lib nor the html structure. So, I think that it would be good to have something like

$('div').bind('css-change', function (){ 
    $('h1').css('fontSize',$('div')Text.css('fontSize'));
})

Any ways to have something like .bind('css-change') ?

Upvotes: 0

Views: 612

Answers (2)

Armin
Armin

Reputation: 15978

jQuery has implemented in version 1.4.3: cssHooks

$.cssHooks["someCSSProp"] = {
    get: function( elem, computed, extra ) {
      // handle getting the CSS property
    },
    set: function( elem, value ) {
      // handle setting the CSS value
    }
};

Upvotes: 0

Sarah Gro&#223;
Sarah Gro&#223;

Reputation: 10879

Afaik there is no event that is triggered on css change... Why not change the css of the <h1> via JS and set it to inherit the font-size?

$('h1').css('fontSize','inherit');

Upvotes: 1

Related Questions