【问题标题】:Include page in a div using onclick使用 onclick 在 div 中包含页面
【发布时间】:2013-12-03 03:43:41
【问题描述】:

我想将一些页面包含到一个 div 中,但我不知道如何。有问题的代码如下

我想在内容 div 中包含一个页面,所以当我在导航栏中单击联系人时,contact.php 需要加载到 index.php 的内容 div 中,当我在导航栏中单击关于我们时,关于.php 页面包含在 index.php 的内容 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>

【问题讨论】:

标签: php html include require


【解决方案1】:

像下面这样重新编码 ul

 <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

【讨论】:

  • 这最终会变得非常像意大利面条。
猜你喜欢
  • 2013-10-21
  • 1970-01-01
  • 2012-10-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-11
  • 1970-01-01
相关资源
最近更新 更多