This code only seems to work in Firefox. Safari and Opera don’t like it:
alert($("<body>").css("background-color"));
I’ve tried other methods too which are even less successful.
alert(document.getElementsByTagName("body")[0].styles.backgroundColor);
alert(document.body.styles.backgroundColor);
I’ve tested these browsers on Mac – and haven’t tested this in IE (yet). Any ideas?
Try:
(i.e. without the angle brackets around
body). See the jQuery docs on the CSS function, and the docs on jQuery Selectors.