【发布时间】:2015-09-10 13:50:34
【问题描述】:
我有 2 页 html。一页内容仅包含所有菜单,这是我的 index.html。第二个 html 文件或 home.html 包含所有菜单的所有数据。我的意思是,来自不同菜单的所有数据都在这个页面中。
我想要的是,一旦我单击 index.html 中的特定菜单,只有该菜单的内容会显示在 home.html 中的屏幕中。
这是我在 index.html 中的代码
<div class="list-group topics">
<a href="home.html #headrest" onclick="headrest_main()" class="list-group-item list-group-item-success sub_topic"><i class="fa fa-circle-o text-red"></i> <span>Headrest Guide Clearance</span></a>
</div>
主页.html
<aside class="main-sidebar">
<!-- sidebar: style can be found in sidebar.less -->
<section class="sidebar">
<!-- /.search form -->
<!-- sidebar menu: : style can be found in sidebar.less -->
<ul class="sidebar-menu">
<!-- <li class="header">MAIN NAVIGATION</li> -->
<li><a href="#headrest" onclick="headrest()"><i class="fa fa-circle-o text-aqua"></i> <span>Headrest Guide Clearance</span></a></li>
<!-- <li class="header">LABELS</li> -->
<li><a href="#structures" onclick="structures()"><i class="fa fa-circle-o text-red"></i> <span>Structures</span></a></li>
<li><a href="#foams"><i class="fa fa-circle-o text-yellow"></i> <span>Foams</span></a></li>
<li><a href="#fasteners"><i class="fa fa-circle-o text-teal"></i> <span>Fasteners</span></a></li>
<li><a href="#recliner"><i class="fa fa-circle-o text-olive"></i> <span>Recliner Mechanism</span></a></li>
<li><a href="#plastics"><i class="fa fa-circle-o text-teal"></i> <span>Plastics</span></a></li>
<li><a href="#trims"><i class="fa fa-circle-o text-olive"></i> <span>Trims</span></a></li>
<li><a href="#seat"><i class="fa fa-circle-o text-olive"></i> <span>Seat Tracks</span></a></li>
</ul>
</section>
<!-- /.sidebar -->
</aside>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header hide">
<h1>
Dashboard
<small>Control panel</small>
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
<li class="active">Dashboard</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Main row -->
<div class="row">
<div id="headrest">
<h1 class="title_topic">Headrest Guide Clearance</h1>
</div>
</div><!-- /.row (main row) -->
<div class="row">
<div id="structures">
<h1 class="title_topic">Structures</h1>
</div>
</div><!-- /.row (main row) -->
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
Javascript:
function headrest_main() {
document.getElementById("headrest").innerHTML='<object type="text/html" data="home.html"></object>';
}
但是这里的代码仍然不起作用。有没有一种方法可以加载 HTML 文件,但只能加载特定的 div?这确实是我想实现的,但我仍然不知道怎么做。
【问题讨论】:
-
你可以使用
$.load -
我将如何实现它?
-
其实这个不一样。这是不同的场景。
-
你在
index.html还有什么?
标签: javascript jquery html css