This question already has an answer here:
I have created a page with Ajax function (jQuery & PHP). My problem is when I load content via Ajax in my page. I want to read width of images placed inside of Ajax-container.
I noticed something quite remarkable.
My script:
<script>
$(window).ready(function () {
var bildBreite = $("#wrapper > #target-image").width();
alert(bildBreite);
$("#wrapper > #image-wrapper").css({"width": bildBreite});
});
</script>
It does not work, but when I insert alert ("load"); then work it.
<script>
$(window).ready(function () {
alert("Load");
var bildBreite = $("#wrapper > #target-image").width();
alert(bildBreite);
$("#wrapper > #image-wrapper").css({"width": bildBreite});
});
</script>
What happens here, how can I read the image width?
</div>