Jquery加载html文件 [英] Jquery Load html file

查看:58
本文介绍了Jquery加载html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是源代码:

this is the source code :

<!DOCTYPE html>
<html>
    <head>
        <title>My Awesome Website</title>
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
         <script>
         $(document).ready(function(){

               $('#container').load('t.html');

           });

        </script>
    </head>
    <body>

        <noscript>
            <h1>Please enable Javascript!</h1>
        </noscript>

        <div id="container">

        </div>

    </body>
</html>







加载文件:t.html




load file : t.html

<h1>Hello </h1>



plz帮助,它无法正常工作,它在google crome浏览器中不起作用,


plz help ,it can not work,it does not work in google crome browser ,

Version 35.0.1870.2

推荐答案

document )。ready( function (){
(document).ready(function(){


' #container')。load(' t.html');

});

< / script >
< / head >
< 正文 >

< script >
< h1 > 请启用Javascript!< / h1 >
< / no script >

< div id = 容器 >

< / div >

< / body >
< / html >
('#container').load('t.html'); }); </script> </head> <body> <noscript> <h1>Please enable Javascript!</h1> </noscript> <div id="container"> </div> </body> </html>







加载文件:t.html




load file : t.html

<h1>Hello </h1>



plz帮助,它无法正常工作,它在谷歌crome浏览器中不起作用,


plz help ,it can not work,it does not work in google crome browser ,

Version 35.0.1870.2


您的代码很好,load()方法从服务器加载数据并将返回的数据放入选定的元素。

你必须把Web服务器上的两个文件,并通过浏览器访问主文件。
Your code is fine, The load() method loads data from a server and puts the returned data into the selected element.
You have to put both files on a web server and access the main one through the browser.


这篇关于Jquery加载html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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