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

  • Home
  • SEARCH
  • 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 8730031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:56:27+00:00 2026-06-13T08:56:27+00:00

What I have: I’m using jQuery to hide the last few list items in

  • 0

What I have:

I’m using jQuery to hide the last few list items in an unordered list.

My problem:

The list items appear on the page until the page loads and the jQuery kicks in (which is undesirable).

EDIT: I cannot edit the HTML. Since I can’t selectively add classes I can therefore not rely on pure CSS. I’m using a jQuery selector to target the last two list items.

My code:

Whether I use the hide() function or addclass() + display:none, I experience the same problem.

<ul id="some_menu">
    <li><a href="#">Enkidu</a></li>
    <li><a href="#">Gilgamesh</a></li>
    <li><a href="#">Epic</a></li>
    <li><a href="#">Sumeria</a></li>
    <li><a href="#">Anunnaki</a></li>
</ul>

<script type="text/javascript">
    jQuery(document).ready(function() {
        //jQuery('ul#some_menu li:gt(2)').addClass("hide_menu_link");
        jQuery('ul#some_menu li:gt(2)').hide();
    });
</script>

<style type="text/css">
    .hide_menu_link{
        display:none;
    }
</style>

Here’s the code on JSFIDDLE though it doesn’t reproduce the problem: http://jsfiddle.net/dominornovus/pB8Mb/2/

  • 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-13T08:56:28+00:00Added an answer on June 13, 2026 at 8:56 am

    By using jQuery(document).ready you are telling jQuery to wait for the document to be ready before executing. So, it will, indeed, wait for the page to be ready (loaded) before it takes action.

    Like others said, if you want some items to be hidden at page start and some other to be available, you should reverse the logic, start with everything hidden and then show want you want to display when the document is ready.

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

Sidebar

Related Questions

Have whats probably a simple problem with using parent in if and each statements
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
have 2 questions : A computer with 32-bit address uses 2-level page table (9
I have a jquery bug and I've been looking for hours now, I can't
Have a SQL problem, adding this model all works correctly, the problem is in
have been using no DOCTYPE but rather simply starting with <html> as per HTML5
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Have some code: using (var ctx = new testDataContext()) { var options = new
**Have it working now. I forgot to populate the Array List. How embarrassing. I'm

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.