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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:11:41+00:00 2026-05-28T02:11:41+00:00

This is my first day coding and using jquery, I figured the best way

  • 0

This is my first day coding and using jquery, I figured the best way to learn is practise.
I want to remove content from #container and add new content from an external page.
Should be quite straight forward right?
I have this so far, but it doesn’t work every time. Any assistance would be great.

js

$(document).ready(function(){

  $('.nav a').click(function(){

      var url = $(this).attr('href')+' #content';

      window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);

      $('#container').load(url);

      return false;       

  });
});

index.html

<html>

<body>

<div id="container">


    <div id="content">
        <div class="nav">
            <a href="index.html" id="home">Home</a>
            <a href="about.html" id="about">About</a>
            index
        </div>
    </div>
</div>

and about.html

<body>

<div id="container">


    <div id="content">
        <div class="nav">
            <a href="index.html" id="home">Home</a>
            <a href="about.html" id="about">About</a>
            about
        </div>
    </div>
</div>

at the moment it only works every other click.

Thanks for looking

  • 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-28T02:11:42+00:00Added an answer on May 28, 2026 at 2:11 am

    You’re replacing your original HTML elements with new ones that you load. But at the same time the click event handlers get removed along with the elements and no longer work.

    In older versions of jQuery you could overcome this using live() instead of click(), but with the latest versions – I’m not up to date. I’m sure someone here will add their $0.02 to help.

    Edit: Turns out you can use on()

    $(document).on("click", ".nav a", function() {
        //code goes here
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My first day using this IDE... is there a way to configure the IDE
I'm using this line to get the beginning time of the first day of
This is my first day using c#. I think it is very easy :(.
This is my first day of jQuery, so bear with me. Currently, I am
This is my first day to design UI using WPF. I have looked up
I am currently getting first day Of this week and last week values with
Using Dozer to map two objects, I have: /** /* This first class uses
#include <iostream> using namespace std; // This first class contains a vector and a
Code first: '''this is main structure of my program''' from twisted.web import http from
I am using this date picker from jqueryui . If you look on that

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.