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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:53:04+00:00 2026-06-12T16:53:04+00:00

Following piece of code produces two alert boxes, first one containing undefined , and

  • 0

Following piece of code produces two alert boxes, first one containing undefined, and second one containing the id attribute. when I add return false to the end, it only shows undefined, and doesnt return the id. I’m quite new in this jquery thing. The idea behind this code is, when you click on <a href="/abcd" id="abc"></a>, show the <ul class="abc"></ul>, which has its display initially set to none.

$(".navgbr-itm").click(function(){
  target_menu = $(this).attr("id");
  alert(target_menu);
  //$("."+target_menu).toggle();
});

I use jquery 1.8.2 and the jquery-ui 1.9 . I’m using jquery ui for sth not related to this snippet (for an image slider). And as a note, I have to cancel the navigation after the click.

html:

<nav id="main-navgbr" class="htmlf-block">  
    <ul id="main-navgbr-itms" class="navgbr-itms">  
      <li id="main-nvgbr-itm-academc" class="navgbr-itm"><a  
        href="/akademik" class="navgbr-itm">Akademik</a></li>  
      <li id="main-nvgbr-itm-idari" class="navgbr-itm"><a  
        href="/idari" class="navgbr-itm">İdari / Personel</a></li>  
      <li id="main-nvgbr-itm-ogrn" class="navgbr-itm"><a  
        href="/ogrenci" class="navgbr-itm">Öğrenci</a></li>  
      <li id="main-nvgbr-itm-arastr" class="navgbr-itm"><a  
        href="/arastirma" class="navgbr-itm">Araştırma</a></li>  
      <li id="main-nvgbr-itm-hast" class="navgbr-itm"><a  
        href="/hastaneler" class="navgbr-itm">Hastaneler</a></li>  
      <li id="main-nvgbr-itm-ktph" class="navgbr-itm"><a  
        href="/kutuphane" class="navgbr-itm">Kütüphane</a></li>  
      <li id="main-nvgbr-itm-bshi" class="navgbr-itm"><a   
        href="/bshi" class="navgbr-itm">Basın / Halkla İlişkiler</a></li>   
      <li id="main-nvgbr-itm-blog" class="navgbr-itm"><a  
        href="/bloglar" class="navgbr-itm">Bloglar</a></li>  
    </ul>
</nav>

I tried the w3c validator with this page and it validates. I’m basically recreating my uni’s website for training purposes. And this file is run via a lighttpd server.

  • 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-12T16:53:05+00:00Added an answer on June 12, 2026 at 4:53 pm

    Try with this:

    <a href="#" class="menuitem" data-target-menu="mymenu">Click Me</a>
    
    <ul id="mymenu" style="display:none;">
        <li>Submenu 1</li>
        <li>Submenu 2</li>
        <li>Submenu 3</li>
        <li>Submenu 4</li>
    </ul>
    
    <script>
    $(function() {
        $('.menuitem').click(function() {
            $('ul#' + $(this).data('target-menu')).toggle();
        }
    });
    </script>
    

    Here I introduce you to $.data jQuery utility. It helps you to store data in specific "data-*" attributes of your tag.

    You can see more on jQuery Documentation:

    http://api.jquery.com/jQuery.data/

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

Sidebar

Related Questions

The following piece of code gives me one very long line of fish: <#><
The following piece of code worked well in one program and caused a bus
the following piece of code works fine when i use it among some code
The following piece of code is used to print the time in the logs:
The following piece of code should read each line of the file and operate
The following piece of code runs fine when parallelized to 4-5 threads, but starts
The following piece of code is working on Android devices and iPhone simulator but
The following piece of code seems to unreliably execute and after and undeterministic time
I have the following piece of code that takes in some words, stores them
I have the following piece of code in my Model: public function getSite() {

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.