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 4082446
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:11:20+00:00 2026-05-20T18:11:20+00:00

I am building an ASP.NET MVC web application and I’m using jQuery for some

  • 0

I am building an ASP.NET MVC web application and I’m using jQuery for some client side programming. I have a category display that gets its data from the database and is dynamically generated on the client side.

When I try to hide the sub-categories in an attempt to create some sort of a customized accordion menu, nothing happens. When debugging I’m trying to alert out the size of the categories collection, and I keep getting zero although everything is being displayed on the screen the way it should. Here’s the code:

//markup (my view-engine is Razor)
<div class="sharwe-categories">
    <ul class="menu menu-vertical menu-accordion">
        @foreach(var topLevel in Model.Categories)
        {
             <li class="topLevel">
                <h3>
                    <a href="#" class="main">@topLevel.Name</a> 
                    <a href="#" class="drop-down"></a>
                </h3>
                <ul class="childCategories">
                    @foreach (var childCategory in topLevel.Children)
                    {
                        <li><a href="#">@childCategory.Name</a></li>
                    }
                </ul>
            </li>
        }
    </ul>
</div>

//Javascript code:
$(document).ready(function () {
    var $categories = $('#sharwe-categories .menu li.topLevel');
    var $categories_children = $('ul.childCategories', $categories).hide();
    var $categories_dropdown = $('a.drop-down', $categories);
});

To be honest, I was never good with jQuery and it always pisses me off because I feel it’s “unpredictable” – well maybe because I prefer working on the back-end stuff instead.

Any help would be much appreciated.

  • 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-05-20T18:11:20+00:00Added an answer on May 20, 2026 at 6:11 pm
    <div class="sharwe-categories">
    
    $('#sharwe-categories .menu li.topLevel');
    

    You’ve got class on div, but trying to find it by # (id). $('.sharwe-categories .menu li.topLevel');

    Working with jquery might feel unpredictable when you are starting and don’t know javascript limitations (like trying to detect element size while it is not inserted in DOM), but eventually you will discover that jQuery actually solves all your cross-browser javascript problems (and much more).

    Quite misleading title by the way 🙂

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

Sidebar

Related Questions

I am building a web application using ASP.NET MVC that has two very distinct
I'm am building my asp.net web application using MVC (Preview 5), and am also
I am building an ASP.NET MVC web application using entity framework DbContext using the
I'm in the process of building my first web application using ASP.NET MVC 2
I'm building a web app using EF Code First and ASP.NET MVC. I have
I am building an ASP.Net MVC 3 web application using Entity Framework 4.1 with
I've started building a ASP net MVC 2.0 web application using SQL Express 2008
I'm building a small web application with ASP.NET MVC 2, using db4o as a
I am currently building a very small/simple web application in ASP.NET MVC with ADO.NET
I am building a web site in C# using asp.NET MVC How can I

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.