I'm using this code to trigger stuff on window resize.
css
@media only screen and (min-width : 320px) and (max-width : 768px) {
.placeholder {
width:100%;
}
js
if ($(window).width() <= 768){
$('#middle').hide();
$('.left').removeClass('hidden');
} else {
$('#middle').show();
$('.left').addClass('hidden');
}
});
However, these is an inconsistency between the CSS media query at 768 and the jquery window width 768 because they do not appear to trigger at the same time. This is something explained on this great article, http://www.fourfront.us/blog/jquery-window-width-and-media-queries
However, when I try to apply this like
if ($(".placeholder").css("width") === "100%") {
$('.left').removeClass('hidden');
$('#middle').hide();
} else {
$('#middle').show();
$('.left').addClass('hidden');
}
This doesn't work. I've tried applying other css values, like a 2px margin, but this also doesn't work. What am I doing wrong? Can anyone help? Many thanks.