本文介绍了使用onclick在div中包含页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在div中包含一些页面,但我不知道如何.有问题的代码如下
I want to include some pages into a div but I don't know how. The code with the problem is below
我想在内容div中包含一个页面,所以当我在导航栏中单击contact时,contact.php需要加载到index.php的内容div中,而当我在导航栏中单击关于我们时,关于.php页面包含在index.php的内容分区中.
I want to include a page in a content div, so when I click on contact in the navigationbar the contact.php needs to be loaded in the index.php's content div and when I click on about us in the navigationbar the about.php page is included into the index.php's content div..
<html>
<body>
<div id="navbar">
<ul>
<li>
home
</li>
<li>
about us
</li>
<li>
contact
</li>
<ul>
<div id="content">
<!--so when the user clicks on contact us there needs
to be an include in this div wich includes the contactus.php page.
-->
<?php include 'contactus.php'; ?>
</div>
</body>
</html>
推荐答案
像下面这样对ul进行编码
Recode ul like below
<ul>
<li id="home">
home
</li>
<li id="aboutus">
about us
</li>
<li id="contact">
contact
</li>
<ul>
$(document).ready(function(){
$("#home").click(function(){
$("#content").load("home.php");
});
});
same for contact and aboutus
这篇关于使用onclick在div中包含页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!