(1) load() 方法从服务器加载数据,并把返回的数据放置到指定的元素中

  1. <div class="head">
  2. <a href="8-1html.html">html</a>
  3. <a href="8-2css.html">css</a>
  4. </div>
  5. <div id="app"></div>
  6. <div class="footer">footer</div>
  7. <script>
  8. //load() 方法从服务器加载数据,并把返回的数据放置到指定的元素中
  9. var htmls=["8-1html.html","8-2css.html"];
  10. //1.一开始让html页面显示
  11. $("#app").load(htmls[0]);
  12. $(".head a").click(function(){
  13. $("#app").load(htmls[$(this).index()])
  14. return false;
  15. })
  16. </script>
//页面:8-1html.html
<p>html</p>

//页面:8-2css.html
<p>css</p>