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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:36:54+00:00 2026-06-15T01:36:54+00:00

I have a menu – each menu item has a class name. When I

  • 0

I have a menu – each menu item has a class name. When I click on the menu item I am using JQuery to find a div with a matching ID name. The problem is that the search isn’t strict. If something has a class name like elo-1 and I have div IDs name elo-1 and elo-11 there is no way (the way I am doing this) to get just elo-1.

I would like to get an exact match. I would like to click on elo-1 and only get elo-1, not elo-1, elo-11, elo-12, etc. Anyone have any ideas?

Here is teh code I am using:

        $(document).ready(function() {

    var myLayoutId = $(this).attr("layoutId");


    $("#start_page").show().siblings().hide();
    $("#navBar").hide();
    $("#refs").hide();

    $("li").click(function() {
        var thisID = $(this).attr("class");
        $("#mainBdy div:#"+thisID).show().siblings().hide();
        $('#mainBdy div[id^="'+thisID+'"]').show();


        $("#mainBdy div:#"+thisID).css("width","30%");
        $("#mainBdy div:#"+thisID).css("margin-left","-80px");
        $("#mainBdy div:#"+thisID).css("margin-top","-50px");
        $("#mainBdy div:#"+thisID).css("float","left");


    });


    $("#start_page_accept").click(function() {
        $("#navBar").show();
        $("#refs").show();
        $("#start_page").hide().next().show();
    });

    $("#menu").collapsible({
        effect: "slide",             // The effect to use when expanding and collapsing the menu. 
        initialCollapse: true       // When true, collapses the menu when the page loads.
    });

});
  • 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-15T01:36:55+00:00Added an answer on June 15, 2026 at 1:36 am

    Modify your selector to avoid starts-with matching:

    $('#mainBdy div[id^="'+thisID+'"]').show();
    

    This matches anything that starts with your value, which is not what you want:

    $('#mainBdy div[id="'+thisID+'"]').show();
    

    This matches only those items whose id attribute is equal to your value.

    Additional Suggestions

    Note also that you’re binding to individual list items:

    $("li").click();
    

    This could become tasking to your app since you’re adding an event handler for every new list item that is placed on the page. Event Delegation is a far better approach, and consists of adding one event handler to the ancestor element, using event-bubbling to respond to events on nested items.

    <ul id="list">
        <li class="edo-1">Edoine Mashlup</li>
    </ul>
    

    Suppose this was our markup (toss in another 100 list items for good measure), the following would be our event-delegation instruction:

    $("#list").on("click", "li", function () {
        $("#" + this.className).show().css({
            width:      '30%',
            marginLeft: '-80px',
            marginTop:  '-50px',
            float:      'left'
        })
        .siblings().hide();
    });
    

    Anytime a click event occurs on, or within our #list element, we will evaluate whether the target (the element that received the click) matches our selector li. If it does, we trigger our function – otherwise, we ignore it and let it bubble up the DOM.

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

Sidebar

Related Questions

I have menu which the active item has an active class on load, which
I have menu designed using jQuery in oracle apex.The menu is like this Parent1
i have menu structure like below <ul class=menu_bg id=menu-main-menu> <li class=menu-item menu-item-type-post_type menu-item-object-page menu-item-653
On the .master file i have... <div id=menu> <ul> <li class=1><a href=#>One</a></li> <li><a href=#>Two</a></li>
I have menu, that is on two different languages.My problem is that, on each
i have menu structure like below, <ul> <li class=menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-1406
I have menu list that contains: <ul class=content_menu tabs> <a href=# name=content_1 class=tab active><li
I have Menu item List All Categories. Problem, that categories do not count articles
I have menu structure like below, <ul class=sub-menu> <li class=menu-item menu-item-type-post_type menu-item-object-page menu-item-34 id=menu-item-34><a
I have problem I cannot find the cause. I have menu and application crashes

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.