javascript - How to calculate and set the height for an element with jQuery? -


say have 1 parent div , 3 child divs so

<div id="parent">     <div id="child1">...</div>     <div id="child2">...</div>     <div id="child3">...</div> </div> 

i want calculate , set height of child3 based on pseudo formula

child3height = parentheight - child1height + child2height

how can write in jquery , set way?

first height of parent $('#parent').height , childs $('#child1').height() , apply simple mathamatics rule , height in variable.

var child3height = $('#parent').height - ($('#child1').height() + $('#child2').height()); 

and store variable in child3 .height() property of jquery

$('#child3').height(child3height); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -