• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Javascript Question

I thought I would post this question on here but not much to do with CI

I have a img which I am using holder.js

<div class="header-wrapper ">
<img id="image" data-src="holder.js/100px380?theme=social" class="img-responsive">

I need to get the height of the img on my javascript but all ways return 0

 var height = $(".header-wrapper img").height();

 alert($(".header-wrapper img").height());

 if ($(document).scrollTop() > height) {
   $(".navbar-fixed-top").css("background-color", "#f8f8f8");
 } else {
   $(".navbar-fixed-top").css("background-color", "#EEEEEE");

Any ideas and examples?
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!

I think, before measuring the height the image has to be loaded first for sure. This does not happen on document.ready event. See https://github.com/desandro/imagesloaded

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.