我創建了一個帶有Ajax功能的頁面(jQuery & PHP)。 我的問題是當我通過Ajax在我的頁面加載內容。我想讀取放置在Ajax容器中的圖像的寬度。jQuery-Ajax獲取Ajax容器內部圖像的寬度
我注意到一些非常了不起的東西。
我的腳本:
<script>
$(window).ready(function() {
var bildBreite = $("#wrapper > #target-image").width();
alert(bildBreite);
$("#wrapper > #image-wrapper").css({"width": bildBreite});
});
</script>
它不工作,但是當我插入警報( 「加載」);然後工作。
<script>
$(window).ready(function() {
alert("Load");
var bildBreite = $("#wrapper > #target-image").width();
alert(bildBreite);
$("#wrapper > #image-wrapper").css({"width": bildBreite});
});
</script>
這裏發生了什麼,我該如何讀取圖像寬度?
你是如何調用你的ajax?你能否也顯示這些代碼? – vusan
– user6834389