jquery - Document Height in Javascript -


help make equivalent javascript code jquery code below

  <script> var httmp=parseint($(document).height()); var htorg   = parseint(httmp-71) $("div.content_box").height( htorg);     </script> 

here attempt javascript code that:

// cross browser function document height // http://james.padolsey.com/javascript/get-document-height-cross-browser/ function getdocheight() {     var d = document;     return math.max(         math.max(d.body.scrollheight, d.documentelement.scrollheight),         math.max(d.body.offsetheight, d.documentelement.offsetheight),         math.max(d.body.clientheight, d.documentelement.clientheight)     ); }  var httmp = getdocheight(); var htorg = parseint(httmp - 71);  var elms = document.getelementsbytagname('div'); var thediv = null;  // search element class content_box (var = 0; < elms.length; i++){   if (elms[i].getattribute('class') === 'content_box'){     thediv = elms[i];     break;   } }  thediv.style.height = htorg + 'px'; 

if have multiple elements same class, should modify loop this:

// search element class content_box (var = 0; < elms.length; i++){   if (elms[i].getattribute('class') === 'content_box'){     thediv = elms[i];     thediv.style.height = htorg + 'px';   } } 

that should set height of elements have class content_box.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -