如何使用jQuery将整个html页面放在div中? [英] How to put a whole html page in a div using jquery?

查看:90
本文介绍了如何使用jQuery将整个html页面放在div中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我希望大家知道我是绝对的初学者,所以请耐心等待我。

我想知道如何将整个html页面放在div中。我试过 $(#footballPlayers)。html(footballplayers.html); 但它显示 footballplayers.html 文本,而不是整个页面。



index.html:



 < HTML> 
< head>
< script type =text / javascriptsrc =jquery1.6.4min.js>< / script>
< script type =text / javascript>
$(function(){
$(div#tabFootballPlayers)。click(function(){
$(#footballPlayers)。html(footballplayers.html);
$(#actionStars)。html();
$(#directors)。html();
});
});
$ b $(function(){
$(div#tabActionStars)。click(function(){
$(#actionStars)。html(actionstars。 html);
$(#footballPlayers)。html();
$(#directors)。html();
});
});
$ b $(function(){
$(div#tabDirectors)。click(function(){
$(#directors)。html(director。 ); $ b $(#actionStars)。html();
$(#footballPlayers)。html();
});
});
< / script>
< link rel =stylesheettype =text / csshref =stylesheet.css>
< / head>
< body>
< div>
< div id =tabFootballPlayers>足球运动员< / div>
< div id =footballPlayers> < / DIV>
< div id =tabActionStars>动作星星< / div>
< div id =actionStars> < / DIV>
< div id =tabDirectors>董事< / div>
< div id =Directors> < / DIV>
< / div>
< / body>
< / html>


解决方案

使用加载

  jQuery(#footballPlayers)。load(footballplayers.html); 

了解更多详情点击这里


First of all I want everyone to know that I am absolute beginner so please be patient with me.

I want to know how am I going to put the entire html page in a div. I tried $("#footballPlayers").html("footballplayers.html"); but it displays footballplayers.html text instead of the whole page.

index.html:

<html>
<head>
<script type="text/javascript" src="jquery1.6.4min.js"></script>
<script type="text/javascript">
 $(function(){
  $("div#tabFootballPlayers").click(function(){
    $("#footballPlayers").html("footballplayers.html");
    $("#actionStars").html("");
    $("#directors").html("");
  });
 });

 $(function(){
  $("div#tabActionStars").click(function(){
   $("#actionStars").html("actionstars.html");
   $("#footballPlayers").html("");
   $("#directors").html("");
  });
 });

 $(function(){
  $("div#tabDirectors").click(function(){
   $("#directors").html("directors.html");
   $("#actionStars").html("");
   $("#footballPlayers").html("");
  });
 });
</script>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div>
 <div id="tabFootballPlayers">Football Players</div>
 <div id="footballPlayers"> </div>
 <div id="tabActionStars">Action Stars</div>
 <div id="actionStars"> </div>
 <div id="tabDirectors">Directors</div>
 <div id="directors"> </div>
</div>
</body>
</html>

解决方案

use load

jQuery("#footballPlayers").load("footballplayers.html");

for more details click here

这篇关于如何使用jQuery将整个html页面放在div中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆