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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:28:45+00:00 2026-06-17T13:28:45+00:00

I am trying to load my navigation bar like this: $.get(nav.html,function(menuData){ $(body).html(menuData); )}; and

  • 0

I am trying to load my navigation bar like this:

$.get("nav.html",function(menuData){
  $("body").html(menuData);
)};

and within “nav.html” we have something like

<td id='menu-item-1'>menu item 1</td>
<td id='menu-item-2'>menu item 2</td>

etc. So then I want to assign an event to each item and I have tried this:

$("#menu-item-1").mousedown(function(response){
  //create an empty table
  $("body").append("table id='menu-item-1-sub-table'></table>");
  //retrieve php data and insert it in the table
  $.get("data.php",function(response){
    $("#menu-item-1-sub-table").html(response);
  });
});

The problem is the event will not fire. It worked when I had the html directly in the javascript, e.g.:

$("body").append("<table><tr><td id='menu-item-1'>menu-item-1</td></tr></table>");

but upon moving it to another file it no longer works.

EDIT

this was one answer that worked:

use

$("body").on('click','#menu-item-1',function(){
etc.
});

because menu-item-1 wasn’t created yet when we tried

$("#menu-item-1).mousedown
  • 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-17T13:28:47+00:00Added an answer on June 17, 2026 at 1:28 pm

    To give you an answer replacing

    $("#menu-item-1").on("click",function(){
      //stuff
    });
    

    with

    $('body').on('click','#menu-item-1', function(){
      //stuff
    }); 
    

    works because when the .on() is delegated #menu-item-1 isn’t on the page yet, but when it is called it can select #menu-item-1

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

Sidebar

Related Questions

I am trying to change the colour of an element within my nav bar
I'm trying to have navigation buttons on my page load content files, but a
I am trying to figure out how to load contents without refreshing navigation bar
I'm trying to get ajax navigation working so here's what I tried: $('nav a').on('click',
I have a problem with out of memory when I'm trying load a few
Trying to load a small .txt file into mysql but get all my data
I trying to load and save setting with this code but when I closing
I'm trying to build a jquery dropdown menu, basically I have the left navigation
I'm trying to develop my first Silverlight navigation application. This application has 2 main
Hei guys. What I am trying to achieve is have my search bar behind

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.