Skip to content

Instantly share code, notes, and snippets.

@craigmdennis
Created February 6, 2012 23:34
Show Gist options
  • Save craigmdennis/1755910 to your computer and use it in GitHub Desktop.
Save craigmdennis/1755910 to your computer and use it in GitHub Desktop.
Detect if element hasLayout in IE and invoke it if false
/**
* If you wonder why filter:alpha(opacity=20); sometimes does nothing,
* Read http://joseph.randomnetworks.com/2006/08/16/css-opacity-in-internet-explorer-ie/
* Use the function below to detect if an element has layout & to apply it dynamically if not
*/
function hasLayout(selector) {
$(selector).each(function (index, element) {
if (element.currentStyle.hasLayout === false) {
$(element).css({
'zoom': 1
});
}
});
}
hasLayout('img');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment