2013-06-18 47 views
0

我做了一个代码,点击不同的链接,具体的分部分别发生变化。动态更改html中的分区

第一个文件是: 的index.html

<div class="wrapper">  
    <div class="grid3 first"> 
     <ul class="categories"> 
      <li><a id="Engineering">Aerospace</a></li> 
      <li><a id="Productive">Automotive</a></li> 
      <li><a href="Chemicals">Chemicals</a></li> 
     </ul> 
    </div> 
    <section id="neeraj_content">  
     <div class="grid19" id="Engineering" > 
      <h2>Grow service revenue with world-class<br/> 
      lifecycle service and support.</h2> 
      <p>some displaying content here that appears in the division grid19 </p> 
     </div> 
    </section> 
</div> 

在这个索引文件,我有一个js

<script> 
    $(document).ready(function(){ 
     $('#neeraj_menu ul li a').click(function(){ 
      $('#neeraj_content').load('division.html #' + $(this).attr('href')); 
      return false; 
     }); 
    }); 
</script> 

现在我已经另一个名为HTML文件division.html其中其他内容必须出现在分格19中必须出现在该特定位置

 <div class="grid19" id="Engineering" > 
      <h2>Grow service revenue with world-class<br/> 
      lifecycle service and support.</h2> 
      <p>some displaying content here that appears in the division grid19 </p> 
     </div> 
    </section> 
</div> 

     <div class="grid19" id="Productive" > 
      <h2>Grow service revenue with world-class<br/> 
      lifecycle service and support.</h2> 
      <p>some displaying content here that appears in the division grid19 </p> 
     </div> 
    </section> 
</div> 

     <div class="grid19" id="Chemicals" > 
      <h2>Grow service revenue with world-class<br/> 
      lifecycle service and support.</h2> 
      <p>some displaying content here that appears in the division grid19 </p> 
     </div> 
    </section> 
</div> 

现在点击生产力或化学物质,该部门的内容必须改变。我在改变它时遇到了问题。它实际上访问了division.html文件中的特定ID。它不工作。有问题。我无法得到错误的地方。 此外,它确实发生了变化,因为我早些时候已经厌倦了它,它已经工作了,现在我已经忘记了它是如何第一次。

回答

0

您参考:

$('#neeraj_menu ul li a').click(function(){ 

但在您提供的ID neeraj的HTML代码没有出现