Last Updated: February 25, 2016
·
622
· redeyes2015

CSS attribute selector reaction

It's easy to find document saying that IE 7 and IE 8 support attribute selector, as long as DOCTYPE declaration is presented.

But I can not find any document mentioning this: When the attribute changes, IE may not react or may not react insantly.

See this jsfiddle: http://jsfiddle.net/AYPQ4/1/

In Firefox 17 and Chrome 23, the 'b' and 'c' button change the color instantly.

But in IE 8, the color is not changed, until you hit 'update'.

It seems that attribute change event does not trigger the re-flow of IE 8, and the effect is postponed until next re-flow. In other words, if IE 8 is considered as a target browser, DON'T use attribute selector to change styles dynamically .

I do not know what behavior other versions of IE have, or whether this behavior is described some elsewhere. I just want to complain... share this a bit. Hope this helps someone.

Oh, forgot to mention: one simple work-around is $(el).hide().show() to force IE to do re-flow.