Want to simplify using jquery to display some html in many files

  Kiến thức lập trình

I have jQuery in html files to display a tag line on the web page. I want to put a line of code in the header, so I don’t have to copy the many lines of jQuery code. I’ll attach a working copy of what I have. I want to load everything that is in the <script src…. thru the end of the footer.html in one line of code in the head.

The Main html.

<!DOCTYPE html>
<html lang="en">
<head>
<title>Dunlavy US Home Page</title>
<link rel="stylesheet" type="text/css" href="common.css">

<script
src="https://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous">
</script>
<script> 
$(function(){
$("#footer").load("footer.html"); 
});
</script> 

</head>
<body>
<h2>This is a sample of a copied bottom line of text using jquery.
<br>
It Works Good.
</h2>
<br>
<div id="footer"></div>
</body>
</html>

Contents of the “footer.html” file.

<p>Copyright © 1999-2024 . Professional Systems Industries, by 3d</p>

New contributor

Ddaved is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT