0

I try to create a single page application via jquery.

The problem is that the click function is not called in the second part.

It can be solved by inserting the click function into the other, but I would need an infinite number of functions to navigate the page.

I have read that the function is exited with a return statement, but then the click function should be callable. That's not the case.

$(document).ready(function() {

  $("#content").load("start.html", function() {
    console.log("start was loaded!");
    return;
  });

  $("#projects").click(function() {
    console.log("#projects has been clicked!");
    $("#content").load("projects.html", function() {
      return;
    });
    return;
  });
});
mplungjan
  • 155,085
  • 27
  • 166
  • 222
  • Assuming the element with ID=projects is in the start.html page, you need to delegate: `$(document).on("click", "#projects", function() {` – mplungjan Jul 16 '21 at 10:37

0 Answers0