0
我試圖在使用.show()
函數顯示元素之前更改.right-content
的高度。我希望新的高度等於通過t .html()
轉換的加載的PHP頁面的高度。如何在顯示元素之前從.load()獲取新高度
在調用.show()
函數之前,我一直無法找到這個高度的方法,因此當頁面加載時,它有時會被切斷或變大(因爲某些頁面比較大/較小,其他)。
有沒有辦法獲取高度並將其更改爲註釋在代碼中的位置?謝謝!!
$(document).ready(function() {
jQuery.easing.def = "easeInOutBack";
$(".right-content")
.hide("slide")
.load("homePage/start.php").html();
$(".right-content")
.show("slide", {direction: "left"}, 750);
$('#footer')
.fadeIn(2000);
$(".button").click(function() {
$(".right-content").hide("slide", {direction: "left"}, 700, function() {
$(this).load("homePage/" + item + ".php", function() {
// figure out how to get the new .load() height and set $(this).height() equal to it
console.log($(this).height());
});
$(this).show("slide", {direction: "left"}, 1000);
});
});
});
爲了獲得高度,它需要在頁面上呈現。您可以將其粘貼在頁面外的某個元素中並讀取該值。 – epascarello