【发布时间】:2015-03-25 15:55:01
【问题描述】:
我拼命地尝试遵循有关使用 JQuery 从外部页面加载 html 元素的基本教程。
我有一个名为 oltest.html 的 html 文档,其中仅包含:
<ol id="projects">
<li>un</li>
<li>deux</li>
<li>trois</li>
</ol>
还有一个 html 文档 test.html,紧挨着第一个加载 ol 元素的文档:
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="Test">
<meta name="author" content="">
<link rel="icon" href="favicon.ico">
<title>Test</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="home.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<!--script src="../../assets/js/ie-emulation-modes-warning.js"></script-->
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div>
<!--ol id="projects">
<li>un</li>
<li>deux</li>
<li>trois</li>
</ol-->
<ol id="new-projects"></ol>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
$( "#new-projects" ).load( "oltest.html #projects li" );
</script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<!--script src="../../assets/js/ie10-viewport-bug-workaround.js"></script-->
</body>
</html>
但这不起作用。有人知道吗?提前致谢。
【问题讨论】:
标签: jquery twitter-bootstrap load external