Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8158451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:36:08+00:00 2026-06-06T17:36:08+00:00

I just can’t figure out or find any solution here, so I chose to

  • 0

I just can’t figure out or find any solution here, so I chose to ask a question.
I have plain css/html drop-down menu code, that works and looks fine, but when I add jquery, the problem begins.
As you can see in example below I am trying to add biggest value of same tree (ul.children li) elements Width as the width of all elements within this tree.
Well, the attribute is added, but the value is 0px and remains even if i try to globalize the element range changing .children to all ul.
What is cousing the code to output 0px instead of needed biggest width value of element.
Thanks in advance!

Here’s the plain HTML code:

<ul>

   <li class="page_item page-item-2"><a href="">Sākumlapa</a></li>

   <li class="page_item page-item-4"><a href="">Par mums</a>

      <ul class="children">

        <li class="page_item page-item-6"><a href="">Galerija</a></li>

      </ul>

   </li>

</ul>

And here is the jQuery code:

                       $(document).ready(function() {

                            var maxWidth = 0;

                            var elemWidth = 0;


                            $('.children li').each(function() {

                                elemWidth = parseInt($(this).css('width'));

                                if (parseInt($(this).css('width')) > maxWidth) {

                                    maxWidth = elemWidth;

                                }

                             });


                            $('.children li').each(function() {

                                  $(this).css('width', maxWidth + "px");

                            });

                       });

And after this is executed you can see that there is style attribute added for the children.li element, but it contains 0px not the biggest width of element.
Here is the Copy&Paste code from browser.

<ul>

   <li class="page_item page-item-2"><a href="http://localhost/wordpress/?page_id=2">Sākumlapa</a></li>

   <li class="page_item page-item-4"><a href="http://localhost/wordpress/?page_id=4">Par mums</a>

      <ul class="children">

        <li class="page_item page-item-6" style="width: 0px;"><a href="http://localhost/wordpress/?page_id=6">Galerija</a></li>

      </ul>

   </li>

</ul>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:36:09+00:00Added an answer on June 6, 2026 at 5:36 pm

    I added this line after document is loaded and before the each function:

        $('.navigation li').hover(function(){
           // here goes the whole code above
        });
    

    This fixed my issue!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just can not figure this out, or find any docs. I have a
I just can't find a simple answer to this simple question I have from
I just can't figure out why i get the error message, I have tried
I just can't figure out how to do it, I have a full file
I just can't figure this out. I have a script that gets data from
I just can't figure it out. I have this shape in res/drawable/start_light.xml <?xml version=1.0
I just can't find a solution to this... I have several dynamic page links
I just can't seem to figure this out. I found some similar Questions here
I just can't figure out, why this slidetoggle does't work. It just runs once:
I just can't figure it out how to set custom validator messages in Zend_Form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.