Query. Как определить ширину экрана на лету
Для определения window width нужно использовать следующий код:
$(document).ready(function() {
// Optimalisation: Store the references outside the event handler:
var $window = $(window);
function checkWidth() {
var windowsize = $window.width();
console.log(windowsize);
}
// Execute on load
checkWidth();
// Bind event listener
$(window).resize(checkWidth);
});