Note that there are some explanatory texts on larger screens.

plurals
  1. POMake an a child div the same height as parent even after parent has resized
    primarykey
    data
    text
    <p>So I have this thing that I am building, and what happens is when a user clicks on a li element, it opens up a popup window that is the same height as the main parent container.</p> <pre><code>&lt;div class="tools"&gt; &lt;ul&gt; &lt;li&gt; &lt;a&gt;Click Me to Open Popup Window&lt;/a&gt; &lt;div class="popup"&gt; &lt;header&gt;Title Goes Here&lt;/header&gt; &lt;ul&gt; List elements that clickable and close the popup. &lt;/ul&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I have everything working correctly using this code:</p> <pre><code>// this is the js that sets the height of the popup. var popHeight = $('.tools').height() - 23; $('.popup ul').css({'height': popHeight + 'px'}); // This is the js that reveals the popup. $('.tools ul li a').live('click', function(){ $(this).parent().find('.popup').addClass('reveal'); }); </code></pre> <p>The basic idea is that the ul of the popup has to be the same height as that of .tools container minus the height of the header.</p> <p>Now, the only problem that occurs is that the height .tools can change because elements are dynamically added to it. So if you have already opened the popup once, then the .tools div height changes, and you click to open the popup again, its height will be the same as it was the first time, it will not resize to be the same height as the new height of .tools.</p> <p>So what can I do with the jquery so that it will recheck the height of .tools before popping up so that it is always the correct height?</p> <p>Thanks!</p> <p>-- EDIT --</p> <p>I forgot to include the js that reveals the popup on click. so I added that above. What happens is the popup is hidden on load, then when you click on the a tag, the popup gets the class .reveal added, which then makes it show up.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload