这是我的代码
var test = jQuery(".ls-wp-fullwidth-container").css("height");
jQuery('#main-home').css({ top: test.height() });
由于变量具有 .css("height"); 在其中,当我删除它时它会起作用,它看起来像这样
var test = jQuery(".ls-wp-fullwidth-container");
jQuery('#main-home').css({ top: test.height() });
它返回顶部:0;由于高度未在样式表中定义。
如果我运行下面的代码,它会返回 .ls-wp-fullwidth-container 的内联样式
jQuery(".ls-wp-fullwidth-container").css("height");
alert(jQuery(".ls-wp-fullwidth-container").css("height"));
我知道只需要进行一些调整,但我不确定是什么。
如果我进入我的样式表并将高度添加到 .ls-wp-fullwidth-container 类中,那么使用第一段代码就可以了。但是我需要返回内联值。