jQuery delaying a script -


i'm using js make 2 divs same height works fine static content, when images/content being loaded in dynamically height being set 0px because imagine script firing before content has been pulled. there way delay firing few seconds correct height gets set? tried timeout function couldnt work

// make stuff same height equalheight = function (container) {  var currenttallest = 0,  currentrowstart = 0,  rowdivs = new array(),  $el,  topposition = 0; $(container).each(function () {      $el = $(this);     $($el).height('auto')     toppostion = $el.position().top;      if (currentrowstart != toppostion) {         (currentdiv = 0; currentdiv < rowdivs.length; currentdiv++) {             rowdivs[currentdiv].height(currenttallest);         }         rowdivs.length = 0; // empty array         currentrowstart = toppostion;         currenttallest = $el.height();         rowdivs.push($el);     } else {         rowdivs.push($el);         currenttallest = (currenttallest < $el.height()) ? ($el.height()) :     (currenttallest);     }     (currentdiv = 0; currentdiv < rowdivs.length; currentdiv++) {         rowdivs[currentdiv].height(currenttallest);     } }); }   $(window).load(function () { equalheight('.equal'); }); $(window).resize(function () { equalheight('.equal'); }); 

your answer not provide enough information provide definite answer, i'm going jump gun , assume tried settimeout calling function, if case instead, try settimeout in function this.

// make stuff same height  equalheight = function (container) {     window.settimeout(function () {  // start settimeout          var currenttallest = 0,             currentrowstart = 0,             rowdivs = new array(),             $el,             topposition = 0;         $(container).each(function () {              $el = $(this);             $($el).height('auto')             toppostion = $el.position().top;              if (currentrowstart != toppostion) {                 (currentdiv = 0; currentdiv < rowdivs.length; currentdiv++) {                     rowdivs[currentdiv].height(currenttallest);                 }                 rowdivs.length = 0; // empty array                 currentrowstart = toppostion;                 currenttallest = $el.height();                 rowdivs.push($el);             } else {                 rowdivs.push($el);                 currenttallest = (currenttallest < $el.height()) ? ($el.height()) : (currenttallest);             }             (currentdiv = 0; currentdiv < rowdivs.length; currentdiv++) {                 rowdivs[currentdiv].height(currenttallest);             }         });     }, 5000); // end settimeout }; 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -