【发布时间】:2021-04-24 07:00:46
【问题描述】:
我正在通过在本地计算机上构建示例网站来学习 HTML/JavaScript。我正在尝试重用代码并通过使用 JQuery 来实现;但是,当我使用 load 函数时,它似乎并没有真正做任何事情。
我正在通过 Google Chrome 浏览器进行采样。
我见过使用其他方法的示例,例如使用 php,直接使用 document.write() 的 JavaScript,但我想知道如何将它与 JQuery 一起使用
我已经试过了:
- --allow-file-access-from-file with google;因为有些帖子显示了一个已知问题
两个 html 文件也位于同一位置。
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>
我做错了什么吗?还是失踪了?
【问题讨论】: