javascript - How to set height of parent, dependent on height of selected element -
I have a scenario where I want to get all the elements with a certain class, and then I want to use the parent div < P>
Lt; Div squared = 'a' & gt; & Lt; Div square = 'b' & gt; & Lt; Div squared = 'c' & gt; ......... & lt; / Div & gt; & Lt; Div class = 'd' & gt; ......... & lt; / Div & gt; & Lt; / Div & gt; & Lt; Div square = 'b' & gt; & Lt; Div squared = 'c' & gt; ......... & lt; / Div & gt; & Lt; / Div & gt; & Lt; Div square = 'b' & gt; & Lt; Div squared = 'c' & gt; ......... & lt; / Div & gt; & Lt; / Div & gt; & Lt; Div square = 'b' & gt; & Lt; Div class = 'd' & gt; ......... & lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;
I want to search all the class D objects, and then I want to set the padding bottom
value of my container class B , the height of the class D in question, plus the padding-bottom value that is currently near the B object.
Try it out:
$ ('D'). Each (function () {$ (this) .Parent (). Css ("paddingbottom", "+ =" + $ (this) .height () + "px");});
Comments
Post a Comment