加载页面时,我想获得面板的顶部。但它显示错误。在 Firefox 和 IE 中,它的说法是“ offset() is undefined ”,而在 Chrome 中,错误是“ Uncaught TypeError: Cannot read property 'top' of undefined ”。请帮忙。
$(window).resize(function () {
tabPanelAdjust();
});
function tabPanelAdjust() {
var theTabPanel = $(".TabPanel");
var tabPanelTop = parseInt(theTabPanel.offset().top);
var winHeight = $(document).height();
tabPanelHeight = winHeight - tabPanelTop;
theTabPanel.css({ "min-height": tabPanelHeight - 20 });
}
<div class="TabPanel">
</div>