javascript - Not getting correct height of a div after adding child elements dynamically? -
i have main div id div1. added child elements(divs, tables, etc) in div1 in document load event. when check height of div1 after adding child elements height not changing. please me...
//html code main div <div id='div1' style="height: 10px"> </div> //javascript in document load event var div1 = document.getelementbyid('div1'); var child1 = document.createelement('div'); child1.setattribute('style', 'height:50px'); div1.appendchild(child1); var height = $("#div1").height(); alert(height);//value of height 10px not 50px
ther typo, replace variable height var height = $("#div1").height();
Comments
Post a Comment