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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:57:19+00:00 2026-05-24T15:57:19+00:00

I use html’s data- attribute on a list of menu links in order to

  • 0

I use html’s data- attribute on a list of menu links in order to tie the links to the div ids of sections of content I want to open when the links are clicked. So if I have a hidden div called “#section1” – the link that would open that link is .

Currently, in order to find the div that matches this link, I use jquery .each() to loop through all the possible elements, but it seems like there should be a better way.

Does anybody know how I could streamline this code and find the matching element without having to run the code in a loop?

Here’s my code:

$('a.hidden_link').click(function(){
    section_ident = $(this).attr('data-ident');
    $('.hidden_section').each(function(index) {
        if ($(this).attr('data-ident') == section_ident){
            section_ref = $(this);
            section_ref.show();
        }
    });
});
  • 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-24T15:57:20+00:00Added an answer on May 24, 2026 at 3:57 pm

    This should work.

    $('a.hidden_link').click(function(){
        $(".hidden_section[data-ident='"+$(this).attr('data-ident')+"']").show();
    });
    

    Jsfiddle, http://jsfiddle.net/playerace/H7jwb/

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

Sidebar

Related Questions

I need to use HTML comments to store specific data, but I don't want
I want to use HTML input type=number on a mobile application, in order to
I use html attribute title to set some hints like this: <a href... title=Go
Is it possible to use HTML tags in objects description, like links? I am
Can I use HTML 5 <nav> for footer links, which is not a primary
We want to use Html.RenderAction in our MVC1.0 project. I have downloaded the Futures
I use HTML DIV tag to format my header with border like this: <h3
I often use HTML template for my application and within the template content there
I want to use HTML template in Timer Job. My timer job is to
I want to use Html Agility Pack which is in a .NET code library.

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.