Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue adding child max width to parent element
    primarykey
    data
    text
    <p>I just ran into issue with JQuery. I made simple drop-down navigation. It is working perfectly.</p> <pre><code> &lt;div id="navigation" class="grid-container"&gt; &lt;div class="menu-wrap grid-85"&gt; &lt;ul class="menu"&gt; &lt;li&gt;&lt;a href=""&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;About&lt;/a&gt; &lt;ul class="submenu"&gt; &lt;li&gt;&lt;a href=""&gt;Sarsauto&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Acedelco&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Services&lt;/a&gt; &lt;ul class="submenu"&gt; &lt;li&gt;&lt;a href=""&gt;Purchase&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Rental&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;MOT&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Catalog&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Contacts&lt;/a&gt; &lt;ul class="submenu"&gt; &lt;li&gt;&lt;a href=""&gt;Find Us&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Contact Us&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="clearfix"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Now I am trying to make parent elements <strong>ul.menu li</strong> width the same as the bigest child element <strong>ul.menu li ul.submenu</strong>. Here is the jquery code:</p> <pre><code> $(document).ready(function(){ var maxWidth = "0px"; $("#navigation ul.submenu").each(function(){ var currentWidth = $(this).css("width"); if(currentWidth &gt; maxWidth){ maxWidth = currentWidth; } }); $("#navigation ul.menu li").css("width",maxWidth); }); </code></pre> <p>Now, what it does is adds attribute <em>style</em> with <em>width=0px</em>, istead of <strong>maxWidth</strong>. Please help me to find the issue. Thank you in advance! :)</p>
    singulars
    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.
 

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