Javascript 如何使用jquery在css中使用窗口高度
我需要什么Javascript 如何使用jquery在css中使用窗口高度,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我需要什么 我需要在类行popbx中添加窗口高度 我想在特定的类中附加窗口高度 var height=$(window).height(); //height say 1200. jQuery('.row flush aligncenter popbx').css({ "height": height + 'px' });; if (page > 4) { $('body').ht
- 我需要在类行popbx中添加窗口高度
- 我想在特定的类中附加窗口高度
var height=$(window).height(); //height say 1200. jQuery('.row flush aligncenter popbx').css({ "height": height + 'px' });; if (page > 4) { $('body').html('<div class="row flush aligncenter popbx" > }
var height=$(window.height(); //高度是1200。 jQuery('.row-flush-aligncenter-popbx').css({“height”:height+'px'});; 如果(第4页) { $('body').html(' }
- 我试着从我的朋友那里帮忙
- $('body').html('style=“height:1200px”')) 工作很好,但为什么在html中使用高度变量会有问题
$('.row.flush.aligncenter.popbx').css("height",$(window).height());
注意:无需添加“px”
修复您的代码:
if (page > 4) {
$('body').html('<div class="row flush aligncenter popbx">');
$('.row.flush.aligncenter.popbx').css({ "height": $(window).height() });;
}
if(第4页){
$('body').html(“”);
$('.row.flush.aligncenter.popbx').css({“height”:$(window.height()});;
}
.row.flush.aligncenter.popbx的引用错误(类名缺少点)
var height=$(窗口).height()+'px';
//高度是1200。
如果(第4页)
{
$('body').html(“”);
$('.row-flush-aligncenter-popbx').css({“height”:height});;
}
试试这个
$( window ).height();
最后一部分可以是$('.row.flush.aligncenter.popbx').height($(window.height());您能解释一下您的答案吗?
$( window ).height();