Refael
asked on
Jquery mobile finding image height
Hello experts,
the below script does not work.
what i am trying to do is to get the first image height so i can set the image container div height. all the images having the same height and width but because i resize it to 80% i need to know the height so i can set the container.
the below script does not work.
what i am trying to do is to get the first image height so i can set the image container div height. all the images having the same height and width but because i resize it to 80% i need to know the height so i can set the container.
$(document).on('pageinit', function() {
var houseContainerHeight = $('#img01').height();
alert (houseContainerHeight);
$('#img02, #img03').hide();
$('#img01Btn').click (function() {
$('#house-container img').hide();
$('#img01').show(500);
});
$('#img02Btn').click (function() {
$('#house-container img').hide();
$('#img02').show(500);
});
$('#img03Btn').click (function() {
$('#house-container img').hide();
$('#img03').show(500);
});
});
<div id="house-container" align="center" style="margin:auto; display:block; overflow:hidden'">
<img id="img01" src="images/ansichten/front.jpg" alt="" style="width:80%; ">
<img id="img02" src="images/ansichten/back.jpg" alt="" style="width:80%;">
<img id="img03" src="images/ansichten/garden.jpg" alt="" style="width:80%;">
</div>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi sonawanekiran,
this is strange it works on my mobile when testing but not locally in the browser.
that's good it works. my question is when i rotate the screen can it re-calculate the image with and height?
this is strange it works on my mobile when testing but not locally in the browser.
that's good it works. my question is when i rotate the screen can it re-calculate the image with and height?
ASKER
Was right to the point! Thank you.
ASKER
i am still getting "0" in the alert. for some reason i do not understand why!?
the script in currently inside the page at the bottom before the closing of the body and the html maybe that's the reason? should it be placed somewhere else?