I have html tree like this
<div class="parent"> <div class="child-1"> </div> <div child="child-2"> </div> </div> <div class="parent"> <div class="child-1"> </div> <div child="child-2"> </div> </div> I need to calculate "child-2" width equal to "parent" minus "child-1". For each parent div. I have something like this but not working property.
$("parent").each(function(){ var all = $(this).width(); var child = $(this).children("child-1").width(); var good = all - child; $("child-2").width(good); }); Can you help me with that?