I'm new to media queries and to jQuery. What I'd like to do is swap header images on a mobile site when the user switches orientation. What I've got so far works, oddly, if the user refreshes the page, but gets it wrong on initial load. Here's the script:
$( document ).ready(function() {
if($.mobile.media("only screen and (min-device-width: 320px) and (max-device-width: 480px) and (orientation: landscape)")) {
$("#FlexgridHeader img").attr("src", "http://example.com/path/to/image/header-480x75+.png");
} else {
$("#FlexgridHeader img").attr("src", "http://example.com/path/to/image/headers/header-320x75+.png");
}
});