I'm learning HTML/JavaScript by building a sample website on my local computer. I am trying to reuse code and doing so by using JQuery; however it doesn't seem to actually do anything when I use the load
function.
I am sampling this via Google Chrome browser.
I've seen examples using other methods such as php, straight javascript using document.write()
, but I would like to know how to use it with JQuery
I have already tried:
- --allow-file-access-from-file with google; as some posts show a known problem
Both html files are in the same location as well.
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<style>
html{
background:radial-gradient(#505154,#28292b) no-repeat center center fixed;
background-size:cover;
}
</style>
<title>WebPage</title>
<link rel="icon" href="logo.ico"/>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<div id="navigation"></div>
<script>
$(function(){
$("#navigation").load("nav.html");
});
</script>
</body>
</html>
nav.html:
<p>This is my include file</p>
Is there something I am doing wrong; or missing?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…