我搜索了整个网站,但找不到任何对我有帮助的东西,所以这里是:
我有这个 html 文件,当您单击 Get extern 时,它应该将 extern.html 中的内容放入名为 content 的 div 中,但是当您单击链接时,它会显示加载,仅此而已。
test.html 文件
<script type="text/javascript" src="jquery-1.9.1.js"></script>
<script type="text/javascript"><!--
$(document).ready(function() {
// select all the links with class="lnk", when one of them is clicked, get its "href" value
// adds a "loading..." notification, load the content from that URL and
// place only the paragraph which is in the #cnt into the tag with id="content"
$('a.lnk').click(function() {
var url = $(this).attr('href');
$('#content').html('<h4>Loading...</h4>').load(url+ ' #cnt p');
return false;
});
});
--></script>
</head>
<body>
<h1>Web page test.html</h1>
<a href="extern.html" title="Get extern" class="lnk">Get extern</a>
<div id="content">Initial content in test.html</div>
extern.html 文件
<h2>Content in extern.html</h2>
<div id="cnt"><p>Some text content in extern.html</p></div>