Code Repeat for HTML Navbar

Asked

Viewed 74 times

0

Good night, brothers! I have a site with a navbar stylized and adapted with the colors and symbols of the customer. However, as there are several pages, the navbar code is being repeated in all of them, and it is several lines of code. I’d like to know somehow that I can include the navbar without having to copy and paste the code. PS: I know that with PHP this is possible, but I didn’t want to use php... I know there is a way to do it by jQuery, this is the one I was looking for.

Thank you!

1 answer

1


There is the jQuery load() method.

<html>
<head>
  <title>Load jQuery</title>
  <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
  <script>
    $(function() {
      $("#menu").load("menu.html");
    });
  </script>
</head>

<body>
  <div id="menu">
    Menu...
  </div>

  <div></div>

Would that be?

  • I think that’s right :D

  • It was not I who asked :D

  • Exactly my dear! Thank you!

  • @Lucas Vicente arrange my noble!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.