Я пытаюсь применить высоту окна к максимальной высоте конкретного div..css() jquery не работает должным образом
$(document).ready(function(){
console.log('Initial Window height:', $(window).height());
$('.wordboard').css({ "max-height": ($(window).height()-150) + 'px' });
//console.log($('.wordboard').css({"max-height": ($(window).height() - 150) + 'px'}));
console.log("Initial max height of $('.wordboard'): ", $('.wordboard').css("max-height"));
$(window).resize(function(){
$('.wordboard').css({ "max-height": ($('body').height()-150) + 'px' });
console.log("$('.wordboard').css('max-height')",$('.wordboard').css('max-height'));
});
});
Однако мой сайт загружен: максимальная высота не применяется. Результат в консоли - это когда загружен веб-сайт:
Initial Window height: 550
script.js:28 Initial max height of $('.wordboard'): undefined
(After i resize the window, the effect is now apply. However, I want to apply as soon as the window is loaded)
script.js:31 $('.wordboard').css('max-height') 718px
script.js:31 $('.wordboard').css('max-height') 723px
script.js:31 $('.wordboard').css('max-height') 728px
script.js:31 $('.wordboard').css('max-height') 733px
Возможно, что-то связано с '??? px', которое не обернуто кавычками. – Mave
Можете ли вы предоставить jsFiddle для репликации вашей проблемы? –