Link to home
Start Free TrialLog in
Avatar of Refael
RefaelFlag for United States of America

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.

$(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>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Kiran Sonawane
Kiran Sonawane
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Refael

ASKER

Hi sonawanekiran,

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?
Avatar of Refael

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?
Avatar of Refael

ASKER

Was right to the point! Thank you.