我有一个 html 页面,供学校使用,我需要制作一个菜单栏。我想把它制作成本地的,所以我决定将 menu.html 上传到 media fire
menu.html
<html>
<body>
<nav class="navbar navbar-inverse"
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand">Practice</a>
</div>
<ul class="nav navbar-nav">
<li class="active"></li>
</div>
</nav>
</body>
我的页面不会加载这个文件,输出中没有任何内容。
practiceblank.html
<html>
<head>
<title>Testing Webpage</title>
<link rel="stylesheet" href="bootstrap.min.css">
<link rel = "stylesheet" type = "text/css" href = "main.css"/>
<link rel='icon' href='favicon.ico' type='image/x-icon'/>
<script>
var clicks = 0;
cps = 1;
function countClicks() {
clicks += 1;
document.getElementById("clicks").innerHTML = clicks;
}
</script>
</head>
<body class="an1">
<div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
jQuery("#div1").load("http://download1473.mediafireuserdownload.com/feen32om7deg/ebw8k296r8caucm/menu.html");
</script>
<!--The rest is personal-->
最佳答案
您应该将库的包含与脚本分开:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(function(){
jQuery("#div1").load("http://download1473.mediafireuserdownload.com/feen32om7deg/ebw8k296r8caucm/menu.html");
});
</script>
希望这对您有所帮助。
关于javascript - jQuery ajax 不会加载代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46552435/